Custom fields?

A

AP

Hi,

I'm trying to populate a word document with data from a database. Every time
the document is opened I wish to repopulate certain fields with updated
information from the database. I am using c# and have a mechanism in place
that opens the document (using the Word COM interface) and at that point
could do this population. My question is what fields can I use in Word that
will allow me to get a handle on them in my C# code, and update the text
that's displayed, and preserve the field information so that the fields can
be updated again in the future.

Thanks for your help,

Adam
 
J

Jezebel

CustomDocumentProperties or DocVariables. They function in much the same
way, with the difference that DocProperties are also visible to the user via
File > Properties > Custom; DocVariables are accessible only through code.
(Also DocVariable fields cause problems with earlier versions of Word if
inserted in footers.)
 
A

AP

These fields also need to be able to be user created (adding a macro to do
this is no problem), and are different depending on the document (we have
~500 documents that will need populating from a database of 100 tables). So
the user needs to be able to add the field and specify the piece of data
that they wish to pull (which we will map to the database somehow).

Thanks,

Adam
 
J

Jezebel

CustomDocumentProperties sound like the answer.


AP said:
These fields also need to be able to be user created (adding a macro to do
this is no problem), and are different depending on the document (we have
~500 documents that will need populating from a database of 100 tables). So
the user needs to be able to add the field and specify the piece of data
that they wish to pull (which we will map to the database somehow).

Thanks,

Adam
 
C

Charles Kenyon

You have some reason to not use mailmerge?
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Charles Kenyon

Mailmerge updates in my headers/footers, although it may not show until I
print or print-preview. This is with Word 2003 but I don't think it was any
different in Word 97. If the information you need in the headers/footers
also appears in the body, you can put it in with a Ref or StyleRef field, as
well.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Charles Kenyon

I just checked it in Word 2000 and print preview updates the merge fields in
the footer. Note, I am talking about Print Preview, not Print Layout.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
A

AP

Doesn't work for me. The only way I have found to get the mergefields in the
header/footer to update is if I call unlink() on the field, which defeats
the purpose of using merge fields.
 
C

Charles Kenyon

And you _are_ going through File => Print Preview?
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
A

AP

Yes.

Charles Kenyon said:
And you _are_ going through File => Print Preview?
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
S

Scoprio540

Have you tried selecting the fields and pressing 'F9'. This shoul
refresh the field.

Failing that try selecting the code and right-clicking, then select th
'Toggle Field Codes' option.

Scorpio54
 

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