form fields and ref fields

N

Nathan Franklin

Hello again list.

In my document I have a form field that appears multiple times in the
document. I have the understanding that I need to use a REF field to display
it in the subsequent fields. I have this part nailed ok. The only problem is
I am adding the data with vb.net and the REF field is not being updated. SO
far I have tried these methods..

Doc.FormFields.Item("City").Result = "Sydney"
Doc.Fields.Update

City has 1 REF Field. This does not update the REF Field.
I have to go Into the document myself and right click the REF field and
click Update.

Any Ideas??

Thanks Nathan
 
G

Greg Maxey

The formfield bookmarked "City" can only appear once. You can have multiple
references to the bookmark using { REF City } or simply { City }

Unless you particularily want to set the value of the formfield with VBA,
you don't need VBA at all to update the references in the main text. Just
click the "calculate on exit" option in the formfield dialog box. If you do
want to set the value using VBA you can try:

Sub Test()
Dim Doc As Word.Document
Set Doc = ActiveDocument
Doc.FormFields("City").Result = "Sydney"
Doc.Fields.Update
End Sub
 
N

Nathan Franklin

Hey greg,

Thanks for your reply

I am using vb.net to generate a document, so I need to explicity set the
value's of the form fields. This works ok but the problem is the REF fields
arn't updating.

The calculate on exit is checked, But I dont think I am entering the field
because I am just setting the value. Is this assumption correct? How can I
explicity update the REF fields with VB

Thanks mate

Nathan
 
G

Greg Maxey

Nathan,

I don't know what else to offer. I don't know anything about VB.net.

This works in a document using VBA. It sets the value of the formfield and
updates the REF fields in the main text story. Are you REF fields located
somewhere other than the main text story (e.g., headers or footers)?
Sub Test()
Dim Doc As Word.Document
Set Doc = ActiveDocument
Doc.FormFields("City").Result = "Sydney"
Doc.Fields.Update
End Sub
 
N

Nathan Franklin

Greg,
The ref fields are just located in the main storey. I guess I will just have
to have a play and see what I find...

Do you have to do soemthing different to update the header and footer
fields? I do have some other fields in the headers and footers, will I have
to use a different method.

thanks greg

nathan
 

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