Reading (bookmark) from doc - working with in macro - returning to

T

THE Burg

Is there a way to read the value of a bookmark (numeric) from a document into
a macro, calculate a number of resultant varialbes using math and logic
functions, then populate fields (bookmarked or docvar) back in the document?
Details follow.

I have been tasked with creating Work Instruction (WI) documents in Word
2003 for our manufactured parts. Management wants a unique printed document
for every part number, however our part mix is VERY family-of-parts oriented.
Each part family may have 10s or 100s of almost identical versions where
only a few things change from one to next. One method of detailing these
differences is with a single drawing that includes a table showing the
different dimensions etc. from P/N to P/N. I have successfully dealt with
these using mail merge & excel workbooks.

Now I've come across a parametric version. In this case, the last few
digits of the P/N are a dimension and other dimensions are calculated from
this value. Initial example was fairly simple & I handled by using an ASK to
get the unique dimension and simple FORMULA functions to populate the
document. A simple macro, attached to a custom toolbar button, updates the
controlling variable (bookmarked) and then updates all fields in doc body and
header.

Latest example has more, and more complex calculations and looks like too
much for FORMULA. Would like to take the value from the ASK, add
calculations and logic to the simple macro to calculate all resulting values
then update all fields in document. Want to avoid a form if possible because
ultimate users may be very light in Word knowledge and because it would
introduce a third method to the mix for creating WIs. Would like to make it
look just like the initial parametric WI.
 
D

Doug Robbins - Word MVP

The .Range property of a bookmark will return the information that is
inserted into it

Dim anumber as Range

Set anumber = ActiveDocument.Bookmarks("BookmarkName").Range
MsgBox anumber.text

Do you really need to use the ASK field however. Relying on user input is
prone to error.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top