{"id":25587,"date":"2019-05-10T23:14:03","date_gmt":"2019-05-10T21:14:03","guid":{"rendered":"http:\/\/help.qualiware.it\/qw-help\/?p=25587"},"modified":"2019-05-10T23:14:19","modified_gmt":"2019-05-10T21:14:19","slug":"rimozione-dei-campi-qualiware-in-un-documento-word","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/rimozione-dei-campi-qualiware-in-un-documento-word\/","title":{"rendered":"Rimozione dei campi QualiWare in un documento Word"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\u2018 Grazie alla libreria OpenXml SDK di Microsoft, inclusa dalla release 2015.05b della piattaforma\r\n\r\n\u2018 web QWay\/QualiWare, \u00e8 possibile con poche righe di codice aggiungere contenuti ad un documento Word esistente.\r\n\r\n\u2018 Il seguente frammento di codice rimuove i campi QualiWare presenti in un documento Word sostituendoli col testo che contengono\r\nDim path_doc As String\r\n\r\n\u2018 Recupera il percorso del documento corrente\r\npath_doc = \"&lt;percorso del documento&gt;\"\r\n\r\nDim myDoc As DocumentFormat.OpenXml.Packaging.WordprocessingDocument = DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(path_doc, True)\r\nDim mainPart As DocumentFormat.OpenXml.Packaging.MainDocumentPart = myDoc.MainDocumentPart       \r\n\r\nDim cc as DocumentFormat.OpenXml.Wordprocessing.FieldCode\r\nDim cc0,cc2\r\n\r\nIf not myDoc.MainDocumentPart.HeaderParts Is Nothing\r\n    For Each header as DocumentFormat.OpenXml.Packaging.HeaderPart In myDoc.MainDocumentPart.HeaderParts\r\n        For Each cc In header.RootElement.Descendants(Of DocumentFormat.OpenXml.Wordprocessing.FieldCode)()\r\n            If DBDollar(\"DOCPROPERTY\",cc.text)\r\n                cc0=cc.parent.PreviousSibling\r\n                cc2=cc.parent.NextSibling\r\n\r\n                cc0.remove\r\n                cc.parent.remove\r\n                cc2.Remove\r\n            End If\r\n        Next\r\n    Next\r\nEnd If\r\n\r\nFor Each cc In myDoc.MainDocumentPart.RootElement.Descendants(Of DocumentFormat.OpenXml.Wordprocessing.FieldCode)()\r\n    If DBDollar(\"DOCPROPERTY\",cc.text)\r\n            cc0=cc.parent.PreviousSibling\r\n            cc2=cc.parent.NextSibling\r\n\r\n            cc0.remove\r\n            cc.parent.remove\r\n            cc2.Remove\r\n    End If\r\nNext\r\n\r\nIf Not myDoc.MainDocumentPart.FooterParts Is nothing\r\n    For Each footer as DocumentFormat.OpenXml.Packaging.FooterPart In myDoc.MainDocumentPart.FooterParts\r\n        For Each cc  In footer.RootElement.Descendants(Of DocumentFormat.OpenXml.Wordprocessing.FieldCode)()\r\n            If DBDollar(\"DOCPROPERTY\",cc.text)\r\n                cc0=cc.parent.PreviousSibling\r\n                cc2=cc.parent.NextSibling\r\n\r\n                cc0.remove\r\n                cc.parent.remove\r\n                cc2.Remove\r\n            End If\r\n        Next\r\n    Next\r\nEnd If\r\n\r\nmainPart.Document.Save()\r\nmyDoc.Close()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u2018 Grazie alla libreria OpenXml SDK di Microsoft, inclusa dalla release 2015.05b della piattaforma \u2018 web QWay\/QualiWare, \u00e8 possibile con poche righe di codice aggiungere contenuti ad un documento Word esistente. \u2018 Il seguente frammento di codice rimuove i campi QualiWare presenti in un documento Word sostituendoli col testo che contengono Dim path_doc As String&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[71],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/25587"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=25587"}],"version-history":[{"count":0,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/25587\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=25587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=25587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=25587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}