{"id":25585,"date":"2019-05-10T23:09:08","date_gmt":"2019-05-10T21:09:08","guid":{"rendered":"http:\/\/help.qualiware.it\/qw-help\/?p=25585"},"modified":"2019-05-10T23:09:08","modified_gmt":"2019-05-10T21:09:08","slug":"aggiunta-di-un-testo-ad-un-documento-word","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/aggiunta-di-un-testo-ad-un-documento-word\/","title":{"rendered":"Aggiunta di un testo ad 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 inserisce in un documento Word un testo all'interno di una parte identificata da un segnalibro\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 bkmStart As DocumentFormat.OpenXml.Wordprocessing.BookmarkStart= myDoc.MainDocumentPart.Document.Body.Descendants(Of DocumentFormat.OpenXml.Wordprocessing.BookmarkStart)().FirstOrDefault(Function(x) x.Name = \"&lt;nome del segnalibro&gt;\")\r\nDim bkmEnd As DocumentFormat.OpenXml.Wordprocessing.BookmarkEnd= myDoc.MainDocumentPart.Document.Body.Descendants(Of DocumentFormat.OpenXml.Wordprocessing.BookmarkEnd)().FirstOrDefault(Function(x) x.id.Value= bkmStart.id)\r\n\r\nDim P As DocumentFormat.OpenXml.Wordprocessing.Paragraph=New DocumentFormat.OpenXml.Wordprocessing.Paragraph\r\n\r\nDim R As DocumentFormat.OpenXml.Wordprocessing.Run = p.AppendChild(New DocumentFormat.OpenXml.Wordprocessing.Run())\r\nDim RP As DocumentFormat.OpenXml.Wordprocessing.RunProperties = R.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.RunProperties())\r\nDim b As DocumentFormat.OpenXml.Wordprocessing.Bold = New DocumentFormat.OpenXml.Wordprocessing.Bold()\r\nb.Val = true\r\nRP.AppendChild(b)\r\n\r\ndim fs As DocumentFormat.OpenXml.Wordprocessing.Fontsize = New DocumentFormat.OpenXml.Wordprocessing.FontSize()\r\nfs.Val = \"36\"\r\nrp.Append(fs)\r\n\r\nR.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Text(\"Prima riga\"))\r\nR.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Break())\r\nR.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Text(\"Seconda riga\"))\r\nR.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Break())\r\nR.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Text(\"Terza riga\"))\r\n\r\nbkmEnd.InsertBeforeSelf(P)\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 inserisce in un documento Word un testo all&#8217;interno di una parte identificata da un segnalibro Dim path_doc As&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\/25585"}],"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=25585"}],"version-history":[{"count":0,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/25585\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=25585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=25585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=25585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}