Inserting Fields Via Code

M

ML

As a follow-up to a previous discussion on if it was possible to insert
field codes inside another field (which doesn't seem possible) I was
wondering how can you insert a field code into a document at say the end of
a paragraph so that it inserts the field codes themselves and not just the
text?
 
M

ML

The other side of this would be removing fields. Is there a way to do a
find and replace based on a fields name?
 
C

Charles Kenyon

Look into manually creating your fields and making them AutoText entries.
You can then insert the AT entry at your desired point with code.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: 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.
 
M

ML

Can you embed an Autotext entry that contains fields into another field in a
document and have the field code inserted still function?
 
H

Howard Kaikow

you can programmatically insert fields within fields.
first insert the outer field, then set the range/selection to be within the
field just inserted and then insert another field, etc.
 
M

ML

How do you get the range of a pre-existing field that was manually inserted
into the document?
What I need to do is set the contents of a field to a new field in code, so
that all references now show the inserted value.
 
H

Howard Kaikow

ML said:
How do you get the range of a pre-existing field that was manually inserted
into the document?
What I need to do is set the contents of a field to a new field in code, so
that all references now show the inserted value.

You will have to either write the code to find the pre-existing field, or
you can write the code to use a field you have mabually selected.

Then you add code to modify the content of the field, as needed, inserting
another field within the old field.

How to do tihs depends on the details of what you require.

You will need to use the Range or Selection objects to position things
appropriately. then insert/replace text/fields where you wish.
 

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