Text field in text box does not update on Fields.Update( )

S

StefanM

Hi,

I have a german word 2003 document that contains some (auto-) text
fields that get filled via a program (using Word's ActiveX interface).
After all text fields are set I call Fields.Update( ) method. All
fields get updated except the address field. This field is in a text
frame (not sure about the exact Word terminus beause I'm using a
german word version, maybe it's called text box).

Once the document prints, it gets updated automatically. Or by
clicking the field and hitting F9. But at first the user thinks that
something went wrong because he just sees "R_Address" (the field name)
in the the text box.

Is there any way to update this field with VBA/macro, too?

TIA,
Stefan
 
G

Gordon Bentley-Mix

Stefan,

Because text boxes (the English term) are in a different story from the main
document, Fields.Update doesn't update the fields in them. You could write
code to address this problem by cycling through all of the stories in the
document (and all of the shapes in each story), but there is a "shortcut"
workaround using the .PrintPreview method. This should update all fields in
the document automatically - especially since you say that the fields are
updating correctly when the document is printed. The code is as simple as:

ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
L

Lene Fredborg

Note that not all types of fields are updated when changing to Print Layout
view and back. The following article describes which fields are updated in
which situations:
http://support.microsoft.com/kb/211629

If “(auto-) text†means that the fields inserted are of the type AutoText, I
am afraid they will not update using the Print Layout method (neither
according to the article nor to the test I just made).

A macro that updates all fields can be used instead. You will find such
macro here:
http://www.gmayor.com/installing_macro.htm

Alternatively, you could convert the text box to a frame. Fields in frames
will be updated together with “normal†text since a frame resides in the text
layer of the document. Conversion to frame can be made via the Text Box tab
in the Format Text Box dialog box.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
S

StefanM

Note that not all types of fields are updated when changing to Print Layout
view and back. The following article describes which fields are updated in
which situations:http://support.microsoft.com/kb/211629

If “(auto-)text” means that the fields inserted are of the typeAutoText, I
am afraid they will notupdateusing the Print Layout method (neither
according to the article nor to the test I just made).

A macro that updates all fields can be used instead. You will find such
macro here:http://www.gmayor.com/installing_macro.htm

Alternatively, you could convert thetextbox to aframe. Fields in frames
will be updated together with “normal”textsince aframeresides in thetext
layer of the document. Conversion toframecan be made via theTextBox tab
in the FormatTextBox dialog box.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word








- ZitiertenTextanzeigen -

Lene,

first sorry for answering a bit late but first I was out of office and
then "out of order"...

thanks for pointing me in the right direction of different "Stories"
inside a word document. I now also call update for the fields in the
other stories and now the document displays correctly

Thank you!
Stefan
 

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