Inserting Field Codes into a custom property field

M

ML

I need to be able to insert a field code into an existing custom property
field via code.

Basically I have an embedded field on a document. What I want to do is then
set the contents of this to be another field which is a page level
classification marker.

If I try and insert the field it just puts in the associated text.

Is there a way to do it so the field is inserted and is functional?

The field I want to insert is this:
{ quote (C) { Seq C \r {PAGE} \h }}

Here is what I am trying to do in my code:
ActiveDocument.CustomDocumentProperties("Document number") = "{ Quote (C)
{ Seq C \r {PAGE} \h }}"

This code ends up putting in the text, and not the resulting embedded
fields.
 
J

Jonathan West

What you are trying to do is impossible this way. The curly braces in the
field code are not characters, but field braces inserted by pressing
Ctrl-F9.

If you want the field result to go into a custom property, first you must
mark the field with a bookmark. Maybe call it "DocNum"

Then go to File Properties, add a custom propert, click the "Link to
content" checkbox and select the "DocNum" bookmark. The property will now
always match the visible text of the bookmark.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
M

ML

I need the actual field codes itself to be on the page, just not the result.
The header checks for the given seq in the field code to determine if it
exists and thus sets the classification level, so I need a way to actually
place the coded field onto the page at a specific position via code.
 
J

Jonathan West

ML said:
I need the actual field codes itself to be on the page, just not the
result. The header checks for the given seq in the field code to determine
if it exists and thus sets the classification level, so I need a way to
actually place the coded field onto the page at a specific position via
code.

You can't do this through a custom document property.

Take a look at this article, which might help

Inserting nested fields using VBA
http://www.word.mvps.org/FAQs/MacrosVBA/NestedFieldsWithVBA.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
M

ML

Thanks.

It doesn't really need to be a via a custom property, I just need to be able
to place the field code in specific spots via code as I need to place
various field code in that position based on a userform selection.
 

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