我正在使用 Open XML,我应该更改 word 文件标题中的文本。要更改文档中的特定段落,我使用了以下代码:
Dim body = wdDoc.MainDocumentPart.Document.Body
Dim paras = body.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Paragraph)()
Dim header = body.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Header)()
For Each para In paras
For Each run In para.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Run)()
For Each testo In run.Elements(Of DocumentFormat.OpenXml.Wordprocessing.Text)()
If (testo.Text.Contains("<$doc_description$>")) Then
testo.Text = testo.Text.Replace("<$doc_description$>", "replaced-text")
End If
Next
Next
Next
提前致谢!