Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with Referencing Bookmarks 1

Status
Not open for further replies.

swingkyd

Programmer
Jul 10, 2003
34
CA
I'm very new with coding... but here we go:
I have a bookmark in the template file. I am trying to assign the bookmark's value to a variable (a long).

The user enters in an "ASK" field linked to a 'cur_rev' bookmark. I need to take the value of that bookmark (say revision number '5') and save it as a variable called 'current_revision' which is a 'long' in a VBA 'sub' macro.

I can't seem to get this working no matter how much I search in the help files and this forum.

Eventual goal:
The value of this bookmark that gets converted to a long is going to be used to create a table based the current revision entered in the ASK field. (that's the ultimate goal)

code snipit:
Code:
    Dim current_revision As Long
    current_revision = ' code to assign the value of the 'cur_rev' bookmark in the "ActiveDocument"

I'd really appreciate some help!
 
try:

current_revision = Word.ActiveDocument.FormFields.Item(cur_rev).Result

(the syntax may be off a little, I call word from Delphi so it's a little wierd, but should be close)

HTH


Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
unfortunately this did not help..I got a bunch of errors...I've tried the following but it just didn't work... *sigh*
I've tried several variations... all to the effect of:
Code:
    current_revision = CLng(ActiveDocument.Fields.Item("cur_rev").Result)
[\code]

But that gave same error "type mismatch"
it seems like when the "fields" or "formfields" are selected, the "item" can only have an index of type: long...
 
For those that want to know...this is the code I used to make it work....

Code:
Dim cur_rev As Long

' Gets the value of the "cur_rev" bookmark and stores it into "enter_revision"
    ActiveDocument.Bookmarks.Item("cur_rev").Select
    enter_revision = Selection
[\code]

Note, if you want to manipulate the 'enter_revision' as an integer...cast it with CInt()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top