G
Guest
We store the RichTextBox text with format in SQL DB. It looks like
"<p><b>123</b>ABC</p>". When I use this string to generate a Word doc file,
the doc only includes exactly the raw text with tags, no format.
What’s wrong with my Word automation code? Thanks ahead.
Shaw
----- Code Sample -----
Sub Main()
objWordApplication = CreateObject("Word.Application")
objWordApplication.Visible = False
Dim wRng As Word.Range
objDocument = objWordApplication.Documents.Add
wRng = objDocument.Paragraphs(objDocument.Paragraphs.Count).Range
Dim htmlDataObject As New DataObject
htmlDataObject.SetData(DataFormats.Rtf, True, "<p><b>123</b>ABC</p>")
Clipboard.SetDataObject(htmlDataObject)
wRng.Paste()
objDocument.SaveAs("D:\\Docs\MyTestDoc.doc")
objWordApplication.Quit()
End Sub
"<p><b>123</b>ABC</p>". When I use this string to generate a Word doc file,
the doc only includes exactly the raw text with tags, no format.
What’s wrong with my Word automation code? Thanks ahead.
Shaw
----- Code Sample -----
Sub Main()
objWordApplication = CreateObject("Word.Application")
objWordApplication.Visible = False
Dim wRng As Word.Range
objDocument = objWordApplication.Documents.Add
wRng = objDocument.Paragraphs(objDocument.Paragraphs.Count).Range
Dim htmlDataObject As New DataObject
htmlDataObject.SetData(DataFormats.Rtf, True, "<p><b>123</b>ABC</p>")
Clipboard.SetDataObject(htmlDataObject)
wRng.Paste()
objDocument.SaveAs("D:\\Docs\MyTestDoc.doc")
objWordApplication.Quit()
End Sub