Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Accessing the content of a FormField when opening a document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ron.snape@virgin-nospam.net - 22 Nov 2004 14:31 GMT
Hi

I'm relatively new to vba programming in word, and I've got a bit stuck.  I
have a document which consists of a number sections, each of which contains a
number of FormFields.  Each Section is completed by a different individual in
a logical progression.

I've created a separate Formfield called 'FControl' which is empty when the
document is initially opened.  This is updated with the identifier of the
individual/stage being completed at the end of the stage before it is saved
and closed ready for the next individual to open it and do their thing.

I've modified the Document_Open macro so that it tests the value of
'VControl', but I can't seem to access the value as no matter what the
content of 'FControl', it returns a Null value ("")) even though I can see
that it actually contains a valid value such as "EMP" or "LIN".

I'm checking the value using the code :

If ActiveDocument.Formfields("bkFControl").Result = "EMP" then .....

What am I doing wrong?

Any assistance gratefully received.

Thanks

Ron
Jean-Guy Marcil - 22 Nov 2004 15:30 GMT
Ron.snape@virgin-nospam.net was telling us:
Ron.snape@virgin-nospam.net nous racontait que :

> Hi
>
[quoted text clipped - 18 lines]
>
> If ActiveDocument.Formfields("bkFControl").Result = "EMP" then .....

What is the actual name of the field?
In your post you use three names:
   'FControl'
   'VControl'
   "bkFControl"

If it is called "FControl" (I will assume that "VControl" is a typo), why do
you use "bkFControl" in your code?

And what type of field is it?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Ron.snape@virgin-nospam.net - 22 Nov 2004 15:48 GMT
Jean

Sorry - you're right - the 'V' was a typo.

The field is a Text Form Field with the bookmark set to 'bkFControl'.  When
I couldn't get it to work, I then defined a string variable 'FControl' which
I loaded from the Text Form Field result so that I could then test that
instead, but that didn't work either.

Neither of the following statements work as ("") is returned in both
instances :

1)  FControl = ActiveDocument.Formfields("bkFControl").Result
   If FControl = "EMP" then .....

2)  If ActiveDocument.Formfields("bkFControl").Result = "EMP" then ....

Cheers

Ron

> Ron.snape@virgin-nospam.net was telling us:
> Ron.snape@virgin-nospam.net nous racontait que :
[quoted text clipped - 32 lines]
>
> And what type of field is it?
Jean-Guy Marcil - 23 Nov 2004 00:41 GMT
Ron.snape@virgin-nospam.net was telling us:
Ron.snape@virgin-nospam.net nous racontait que :

> Jean
>
[quoted text clipped - 13 lines]
> 2)  If ActiveDocument.Formfields("bkFControl").Result = "EMP" then
> ....

If you double-click on the field, what bookmark name do you see in the
bottom right corner of the property dialog?

> 2)  If ActiveDocument.Formfields("bkFControl").Result = "EMP" then
should return true if, as you say, the formfield contains "EMP".
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Ron.snape@virgin-nospam.net - 27 Nov 2004 13:11 GMT
Jean

Sorry I haven't responded earlier - payroll falling down around my ears!

If I double-click on the field, I get a box headed 'Text Form Field options'
and under Field Settings, the Bookmark name is shown as 'bkFControl'.

By trial & error, I think that I've now solved the problem by using the
instruction :

FControl = ActiveDocument.Formfields("bkFControl").Range.Text

which does return the text value held in the FormField, and my code now
seems to run properly.

Thanks for your assistance.

Regards

Ron Snape

> Ron.snape@virgin-nospam.net was telling us:
> Ron.snape@virgin-nospam.net nous racontait que :
[quoted text clipped - 22 lines]
> > 2)  If ActiveDocument.Formfields("bkFControl").Result = "EMP" then
> should return true if, as you say, the formfield contains "EMP".
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.