|
-
Mar 19th, 2009, 05:55 AM
#1
Thread Starter
Lively Member
[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
-
Mar 19th, 2009, 06:01 AM
#2
Re: Word VBA Multi bookmarks
Try
Code:
ActiveDocument.Bookmarks("TitleDate1").Select
Selection.Text = (frmEndYear.txtDate.Text)
'etc
-
Mar 19th, 2009, 06:30 AM
#3
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 ?
Please Mark your Thread "Resolved",  if the query is solved & Rate those who have helped you
-
Mar 19th, 2009, 06:58 AM
#4
Thread Starter
Lively Member
Re: Word VBA Multi bookmarks
 Originally Posted by Hack
Try
Code:
ActiveDocument.Bookmarks("TitleDate1").Select
Selection.Text = (frmEndYear.txtDate.Text)
'etc
Works like a charm, cheers Hack!
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|