我尝试将格式化文本插入 Word 书签。文本来自多个富文本控件(我们使用 TX Text Control)并附加到书签中。
问题在于标签是按原样编写的并且没有被解释。
oWord = New Word.Application
Dim strFileName As String = "\\...\Template.dot"
oDoc = oWord.Documents.Add(strFileName)
Dim strText As String = ""
Dim strOut As String = ""
txtPart1.Save(strOut, TXTextControl.StringStreamType.RichTextFormat)
strText += strOut
strText += ControlChars.CrLf & ControlChars.CrLf & ControlChars.CrLf
strText += txtPart2.Text
oDoc.Bookmarks.Item("Conditions").Range.Text = strText
oWord.Visible = True
我尝试使用 RTF 或 HTML 格式作为字符串,但行为相同。
我完成了一个“不太好的”解决方案:
oWord = New Word.Application
Dim strFileName As String = "\\...\Template.dot"
oDoc = oWord.Documents.Add(strFileName)
Dim strText As String = ""
txtPart1.Save(strText, TXTextControl.StringStreamType.RichTextFormat)
Clipboard.SetData(DataFormats.Rtf, strText)
oDoc.Bookmarks.Item("Conditions").Range.PasteSpecial(DataType:=Word.WdPasteDataType.wdPasteRTF)
我讨厌使用剪贴板插入格式化文本的想法(RTF 格式,它似乎不适用于 HTML 格式),所以我会等待再接受这个答案......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)