How to update a document

A

Auutumn

I have a large document in which I'd like to have the user enter some values
for several static names, press a button to have Word automatically update
all references to those static names throughout the document.

The table looks like this and there are more name/value pairs. The user will
update the value for each name as required.

Name Value
Current release 1.5.4.7
Upgrade release 1.5.5.1
UI Server name Sterling
DB server name Sterling

Further down in the document are references to these Names such as the
following. For us the Names are Bold and Dark blue so for this post, I put
open/close angle brackets around them.

3. Copy DB_backup from D:\Databases\<UI Server Server Name>

What I'd like is before the table, to place a button label "Update
References". This button will read each value and find its corresponding
reference (or maybe it's called a Bookmark) in the document. Using the table
and example above, the updated line in the document would read:

3. Copy DB_backup from D:\Databases\Sterling

If this is possible, could you provide some simple, step-by-step
instructions on how to do it.

Thx in advance!
 
J

Jay Freedman

Add bookmarks around the entries in the table, and insert cross-references
to those bookmarks in the other locations. To update the cross-references
when the bookmark contents change, switch to Print Preview and back again
(assuming that the option to update fields on printing is checked). That
mechanism can be put into a macro, and the "Update References" button can
then call the macro. The code you need would be something like this:

Sub UpdateRefs()
ActiveWindow.View = wdPrintPreview
ActiveWindow.View = wdPrintView
End Sub

See http://gregmaxey.mvps.org/Repeating_Data.htm for other options.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
A

Auutumn

Thx for the reply. One thing I forgot to mention is that for the name/value
pairs, the values will be changing everytime the document is used. If I was
to use the Textbox form control, could it be assigned a name that could be
referenced in VBA?


Today's date 1/8/2010
Customer Information
Customer name Sterling
City Sterling
State MA
Zip code 01564
Email Address: To (e-mail address removed)

Email Address: CC (e-mail address removed)

Customer UI Page
Water, Electric, or Both Electric
Thermostat page No
Admin's password Mu3LLEr
Encrypted Admin Password WW67g/qxDA==
SSS Release
Current release 1.5.4.7
Upgrade release 1.5.5.1
UI Server name Sterling
DB server name Sterling
Web servers folder name
Go to the Production server and look for the customer name at D:\web
servers Sterling
ServerPortNumber
System Messenger - select customer & hover over the system management
link 4300
SystemManagementPortNumber 4301
RoutingToolPortNumber N/A
ServerInternalURL 192.168.1.100 (Prod)
192.168.1.101 (QA)
192.168.1.102 (Dev)
ServerExternalURL arkserver01
ServerDataUpdateStartTime(Ask Greg) 9
ServerDataEndtime(Ask Greg) 16
Release Files location \\arkserver\ctom\server side software\version
 
J

Jay Freedman

When you insert any form field (text, dropdown, checkbox) from the Forms
toolbar, it is automatically assigned a "bookmark name" that also serves as
the field's name. You can see and change this name in the field's Properties
dialog.

[Note: If you copy and paste form fields instead of inserting them from the
toolbar, you will get fields that have no name. You can manually assign a
name by going into the Properties dialog. For a way to fix this in a macro,
see http://www.word.mvps.org/FAQs/MacrosVBA/AssignNameToFmFld.htm.]

I'd strongly encourage you to change the default names of all fields to
names that are meaningfully related to their contents.

To refer to form fields in a macro, you can use any of these syntaxes:

ActiveDocument.Fields(1)
ActiveDocument.Fields("Text1")
ActiveDocument.FormFields(1)
ActiveDocument.FormFields("Text1")

The Fields collection contains all fields, including ones like Date and Page
fields; and if you use that collection to access a formfield, you can get
only the properties that are valid for all kinds of fields. If you use the
FormFields collection, you can get properties that are specific to
formfields, such as the list of a dropdown or the state of a checkbox. For
text formfields it makes little difference.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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