Variable from document, Calculations in macro, results in document

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.
 
M

macropod

Hi Burg,

You can do some fairly complex stuff with formula fields. To give you an idea of what can be achieved, check out my Word Field Maths
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
or
http://www.gmayor.com/downloads.htm#Third_party
and my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
or
http://www.gmayor.com/downloads.htm#Third_party

If you want to use a macro, you're already going to be introducing an added layer of complexity into the process. One of these
includes macro warnings and having to deal with the associated security issues.

Thus, you might find that using a document with formfields, protected for forms, and whose formfield properties are set to
'calculate on exit', will actually be easier for your intended audience to deal with.
 

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