Open XML을 사용 중이며 단어 파일의 헤더에있는 텍스트를 변경해야합니다. 문서의 특정 단락을 변경하려면 다음 코드를 사용하십시오.OpenXml 단어 파일의 머리글에서 텍스트 편집
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
미리 감사드립니다.
@ andrea85 : 테이블에 포함 된 텍스트를 바꾸는 방법을 보여주기 위해 답변을 업데이트했습니다. 답변의 왼쪽에있는 빈 화살표를 클릭하면 도움이된다면 동의/upvote 내 대답. – Hans