Results 1 to 5 of 5

Thread: [RESOLVED] bookmarks and Tables

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [RESOLVED] bookmarks and Tables

    Hello,

    I'm developing a template thats updated every financial year, it contains the same year date in it about a 100 times "2008/09" depending on which year its about. I've managed to automate it via a VBA form but the sheer number of bookmarks makes it a up hill task,

    Quote Originally Posted by koolsid View Post
    Something like this?

    Code:
    Private Sub cmd_ok_Click()
        Dim I As Long, J As Long, K As Long
        For I = 1 To 7
            'Entering financial year date into Heading 1
            ActiveDocument.Bookmarks("TitleDate" & I).Select
            Selection.Text = (frmendyear.txtdate.Text)
            DoEvents
        Next I
    
        For J = 1 To 4
            'Entering financial year date into standard text
            ActiveDocument.Bookmarks("textdate" & J).Select
            Selection.Text = (frmendyear.txtdate.Text)
            DoEvents
        Next J
    
        For K = 1 To 4
            'Entering in 'To' Financial date
            ActiveDocument.Bookmarks("todate" & K).Select
            Selection.Text = (frmendyear.txtto.Text)
            DoEvents
        Next K
    End Sub
    Many thanks to Koolsid, the above code works really well, although I've had to put in a few tables into my document, and I added in the extra code, but alas I get a "runtime error '424' Object required". it gets hung up on the "Selection.Text = (frmenedyear.txtdate.Text)"

    An help would be greatly appriciated.

  2. #2
    Lively Member fba1's Avatar
    Join Date
    Aug 2007
    Posts
    119

    Re: bookmarks and Tables

    Question on: frmendyear.txtto.Text

    frmendyear = The name of your userform
    txtto = The object name you are using (textbox)

    The reason I ask is that errors is saying it cant find the object you are referencing. I tried it both ways one creating a userform and naming it frmendyear and then creating a textbox named txtto which worked fine. However after I deleted the userform the error you stated was returned.



  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: bookmarks and Tables

    Thanks for getting back to me fba1, thats correct (userform and txtto(textbox).

    I've ran the form a few times and think by the time it reaches a certain point the "required object" the value in txtdate disapears, which is odd as it only does it when it gets to inputting the date into bookmarks within tables in my document.

    Quote Originally Posted by fba1 View Post
    Question on: frmendyear.txtto.Text

    frmendyear = The name of your userform
    txtto = The object name you are using (textbox)

    The reason I ask is that errors is saying it cant find the object you are referencing. I tried it both ways one creating a userform and naming it frmendyear and then creating a textbox named txtto which worked fine. However after I deleted the userform the error you stated was returned.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: bookmarks and Tables

    Ignore me, I'm being a duffus! I found out it was a typo!

    Thanks for the help anyways

  5. #5
    Lively Member fba1's Avatar
    Join Date
    Aug 2007
    Posts
    119

    Re: bookmarks and Tables

    Quote Originally Posted by Kubull View Post
    Ignore me, I'm being a duffus! I found out it was a typo!

    Thanks for the help anyways
    No worries usually just takes a second glance to see stuff like that, happens all the time



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