Results 1 to 4 of 4

Thread: [RESOLVED] Word VBA Multi bookmarks

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Word VBA Multi bookmarks

    Try
    Code:
    ActiveDocument.Bookmarks("TitleDate1").Select
    Selection.Text = (frmEndYear.txtDate.Text)
    'etc

  3. #3
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    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



  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: Word VBA Multi bookmarks

    Quote Originally Posted by Hack View Post
    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
  •  



Click Here to Expand Forum to Full Width