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/tutorials/aspnet/d4bba585-b517-4834-8476-ff05b085d86e/iis--create-app-pools-v.aspx
I'd try:
Dim BMRange As Word.Range 'if you've got a reference to MSWord.
or
dim BMRange as Object 'if you're using late binding (no reference)
--
Dave Peterson