View Single Post
 
Old 07-14-2011, 12:29 PM
chipnputt chipnputt is offline Windows Vista Office 2007
Novice
 
Join Date: Jul 2011
Posts: 5
chipnputt is on a distinguished road
Default Setting a bookmark range

I have experience in VBA with Access and Excel, I am a novice with word. I have a routine that updates bookmarks in word from a routine in an excel spreadsheet. I keep getting a compile error "Expecting Function or variable". in the code below
Code:
Sub UpdateBookMark()
Dim BmkNm As String, NewTxt As String, BmkRng As Object
BmkNm = "MondayTeams"
Worksheets("Monday").Range("H1:L2").Select
Selection.Copy
With ActiveDocument
  If .Bookmarks.Exists(BmkNm) Then
    Set BmkRng = .Bookmarks(BmkNm).Range
    BmkRng.Text = .Bookmarks(BmkNm).Range.PasteSpecial(DataType:=wdPasteHTML, Placement:=wdInLine, DisplayAsIcon:=False)
    .Bookmarks.Add BmkNm, BmkRng
  Else
    MsgBox "Bookmark: " & BmkNm & " not found."
  End If
End With
Set BmkRng = Nothing
End Sub
The error highlights ".PasteSpecial" as the problem area. Does anyone know how to correct the error. The reason for using the PasteSpecial is that the formatting and layout remains the same as it is in the spreadsheet.

Thanking you in advance....

Last edited by macropod; 07-14-2011 at 03:23 PM. Reason: Fixed code format & tags
Reply With Quote