S
smay
I'm trying to pull strings of HTML from a database table and put them into
Bookmarks in my Word document while retaining the formatting (bold, italics,
bulleted lists, etc) from the HTML tags. The DataObject.SetText does not
recognize the string as HTML, and therefore when I use
ActiveDocument.Range.PasteSpecial DataType:=wdPasteHTML I get the error "The
specified data type is unavailable". I've tried wrapping the string in
<html> and <body> tags, but that doesn't help. I do not want to see the
tags, just the formatted text. Suggestions please!
Call the method below as:
UpdateBookmark 1, "<b>Some text</b>" OR
UpdateBookmark 1, "<html><body><b>Some text</b></body></html>"
Dim MyData As DataObject
Sub UpdateBookmark(BookmarkToUpdate As Integer, TextToUse As String)
Set MyData = New DataObject
MyData.SetText TextToUse
MyData.PutInClipboard
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks("Goal" & BookmarkToUpdate).Range
BMRange.PasteSpecial DataType:=wdPasteHTML
End Sub
Bookmarks in my Word document while retaining the formatting (bold, italics,
bulleted lists, etc) from the HTML tags. The DataObject.SetText does not
recognize the string as HTML, and therefore when I use
ActiveDocument.Range.PasteSpecial DataType:=wdPasteHTML I get the error "The
specified data type is unavailable". I've tried wrapping the string in
<html> and <body> tags, but that doesn't help. I do not want to see the
tags, just the formatted text. Suggestions please!
Call the method below as:
UpdateBookmark 1, "<b>Some text</b>" OR
UpdateBookmark 1, "<html><body><b>Some text</b></body></html>"
Dim MyData As DataObject
Sub UpdateBookmark(BookmarkToUpdate As Integer, TextToUse As String)
Set MyData = New DataObject
MyData.SetText TextToUse
MyData.PutInClipboard
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks("Goal" & BookmarkToUpdate).Range
BMRange.PasteSpecial DataType:=wdPasteHTML
End Sub