[RESOLVED] Word VBA Multi bookmarks
I have a document that needs updating every financial year, apart from a few new stats I have to update the year about 60 times (IE: 2008/09) within the document, so I thought I'd make it a template and have a userform to just input the date and VBA would do the mundane part, but I can't seem to get the code to work,
It says the bookmarks do not exist. (5101) now I think it might be because the Doc has about 6 section breaks, would I need to declare which sections the BM's exist in?
Code:
Private Sub cmd_ok_Click()
Unload Me
'Entering financial year date into Heading 1
Selection.GoTo What:=wbGoToBookmark, Name:="TitleDate1"
Selection.TypeText frmendyear.txtdate
Selection.GoTo What:=wbGoToBookmark, Name:="TitleDate2"
Selection.TypeText frmendyear.txtdate
Selection.GoTo What:=wbGoToBookmark, Name:="TitleDate3"
Selection.TypeText frmendyear.txtdate
Selection.GoTo What:=wbGoToBookmark, Name:="TitleDate4"
Selection.TypeText frmendyear.txtdate
'Entering financial year date into normal text
Selection.GoTo What:=wbGoToBookmark, Name:="NormalDate1"
Selection.TypeText frmendyear.txtdate
Selection.GoTo What:=wbGoToBookmark, Name:="NormalDate2"
Selection.TypeText frmendyear.txtdate
End Sub
Re: Word VBA Multi bookmarks
Try
Code:
ActiveDocument.Bookmarks("TitleDate1").Select
Selection.Text = (frmEndYear.txtDate.Text)
'etc
Re: Word VBA Multi bookmarks
Are all your bookmarks in the main document or as your comments seem to suggest are some of them in the document Header ?
Re: Word VBA Multi bookmarks
Quote:
Originally Posted by
Hack
Try
Code:
ActiveDocument.Bookmarks("TitleDate1").Select
Selection.Text = (frmEndYear.txtDate.Text)
'etc
Works like a charm, cheers Hack!
Quote:
Are all your bookmarks in the main document or as your comments seem to suggest are some of them in the document Header ?
Na, There all in the documents body, thanks for the help though.