|
-
Mar 30th, 2009, 07:02 AM
#1
Thread Starter
Lively Member
[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,
 Originally Posted by koolsid
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.
-
Mar 30th, 2009, 02:29 PM
#2
Lively Member
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.
-
Mar 31st, 2009, 04:07 AM
#3
Thread Starter
Lively Member
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.
 Originally Posted by fba1
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.
-
Mar 31st, 2009, 05:11 AM
#4
Thread Starter
Lively Member
Re: bookmarks and Tables
Ignore me, I'm being a duffus! I found out it was a typo! 
Thanks for the help anyways
-
Mar 31st, 2009, 11:50 AM
#5
Lively Member
Re: bookmarks and Tables
 Originally Posted by Kubull
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|