Public Sub InsertBookMarkText(strBookmark As String, varText As Variant)
On Error GoTo ErrorHandler
Dim BookmarkRange As Range
Set BookmarkRange = WordDoc.Bookmarks(strBookmark).Range
BookmarkRange.Text = varText & ""
WordDoc.Bookmarks.Add strBookmark, BookmarkRange
'BookmarkRange.Select
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 4605 'this method or property is not available because the object is empty
Resume Next
Case 5941, 6028 ' member does not exist/the range cannot be deleted
MsgBox "Bookmark {" & strBookmark & "} There is a mapping error with this document. Please contact your administrator.", vbOKOnly
Resume Next
Case 91 'object variable not set
Resume Next
Case 4218 'type mismatch
Resume Next
Case Else
msgbox Err.Number & vbcrlf & Err.Description & vbcrlf & vbcrlf "Proc: InsertBookMarkText()",vbInformation + vbOKOnly,"Error"
Resume Exit_ErrorHandler
End Select
Resume Exit_ErrorHandler
End Sub