S
Stephen Jackson
I'm writing a VBA program which copies information from Excel into bookmarks in Word. I originally wrote it to be run from the Word document, but it makes more sense to have it in Excel so I'm migrating it over.
The original code worked, and used ActiveDocument throughout, which I've replaced with myDoc.
However, when run it gives the Type Mismatch error when I try to set the bookmark range and I can't figure out why.
myDoc is defined and works well in other places (for instance, if you add the line:
msgbox myDoc.Bookmarks(BookmarkToUse)
into this sub it correctly returns to bookmark name.
The code for the sub is:
Private Sub UpdateBookmark(BookmarkToUse As String, TextToUse As String, FontToUse As String, SizeToUse As String)
Dim BMRange As Range
BMRange.SetRange = myDoc.Bookmarks(BookmarkToUse).Range
BMRange.Text = TextToUse
BMRange.Font.Name = FontToUse
BMRange.Font.Size = SizeToUse
myDoc.Bookmarks.Add BookmarkToUse, BMRange
End Sub
Any help would be much appreciated.
Submitted via EggHeadCafe - Software Developer Portal of Choice
IIS - Create App Pools, Virtual Directories and Web Sites C# .NET
http://www.eggheadcafe.com/tutorial...476-ff05b085d86e/iis--create-app-pools-v.aspx
The original code worked, and used ActiveDocument throughout, which I've replaced with myDoc.
However, when run it gives the Type Mismatch error when I try to set the bookmark range and I can't figure out why.
myDoc is defined and works well in other places (for instance, if you add the line:
msgbox myDoc.Bookmarks(BookmarkToUse)
into this sub it correctly returns to bookmark name.
The code for the sub is:
Private Sub UpdateBookmark(BookmarkToUse As String, TextToUse As String, FontToUse As String, SizeToUse As String)
Dim BMRange As Range
BMRange.SetRange = myDoc.Bookmarks(BookmarkToUse).Range
BMRange.Text = TextToUse
BMRange.Font.Name = FontToUse
BMRange.Font.Size = SizeToUse
myDoc.Bookmarks.Add BookmarkToUse, BMRange
End Sub
Any help would be much appreciated.
Submitted via EggHeadCafe - Software Developer Portal of Choice
IIS - Create App Pools, Virtual Directories and Web Sites C# .NET
http://www.eggheadcafe.com/tutorial...476-ff05b085d86e/iis--create-app-pools-v.aspx