Form Field Name

T

Tom

I am using the code below to identify the current field the user has just
exited from on a protected form:

strFrmFieldName =
Word.ActiveDocument.FormFields.Item(Selection.BookmarkID).Name

This line works great and allows me use only one macro w/Select Case to do
everything I need to do.
My problem arises when I try the same line on a Check Box. The check box
has a bookmark name just like the fields. I can call the check box directly,
i.e.

strValue = activeDocument.FormFields("MyChkBox").CheckBox.Value

But I can't get the name of the Bookmark using the "Selection.BookMarkID".
Any help would be greatly appreciated.

Regards,
Tom C
 
J

Jay Freedman

Tom said:
I am using the code below to identify the current field the user has
just exited from on a protected form:

strFrmFieldName =
Word.ActiveDocument.FormFields.Item(Selection.BookmarkID).Name

This line works great and allows me use only one macro w/Select Case
to do everything I need to do.
My problem arises when I try the same line on a Check Box. The check
box has a bookmark name just like the fields. I can call the check
box directly, i.e.

strValue = activeDocument.FormFields("MyChkBox").CheckBox.Value

But I can't get the name of the Bookmark using the
"Selection.BookMarkID". Any help would be greatly appreciated.

Regards,
Tom C

See http://word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm for another
way to get there.
 
C

Chuck

That's because checkboxes don't seem to have "corresponding bookmarks"
(Selection.BookmarkID returns 0 which according to VBA help indicates there's
no corresponding bookmark). This is of course confusing because the
properties dialog allows you to set a "bookmark" name for the checkbox.

Looks like you're going to have to add a "Case 0" to your Select Case code
to handle check boxes and drop down form fields which also return 0.
 
T

Tom

Thanks Chuck, I can do that also, it just makes my code a bit longer.
Thanks for the quick response.
Tom
 
T

Tom

Thanks Jay, I checked out your link and that is exactly what I'm trying to do
! ! :) Thanks for the assist.

Regards,
Tom
 

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