If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Setting "Bookmark" text in Text Form Field Options dialog
I can add a bookmark for a text field on a Word document
using the following code: ActiveDocument.FormFields(amtIndex).Range.Bookmark s.Add _ Name:=str, _ Range:=ActiveDocument.FormFields(amtIndex).Range Note: "amtIndex" is a defined integer However, I can't figure out the code syntax to use that actually enters the bookmark text in the "Bookmark:" field in the Text Form Field Options dialog form. "Name" doesn't work. The other fields, such as TextInput for "Default number", in the Text Form Field Options dialog have obvious choices as VBA code objects/data members. |
#2
|
|||
|
|||
Setting "Bookmark" text in Text Form Field Options dialog
Hi William,
The form field already has a bookmark associated with it, so you don't need to add one. The one you're adding is "on top of" the field, not the one whose name is shown in the Properties dialog. To change the name of the associated bookmark, use syntax like ActiveDocument.FormFields(amtIndex).Name = str There's an odd situation you can encounter in which the fields don't have a name, and then VBA has trouble assigning one. See http://word.mvps.org/FAQs/MacrosVBA/...ameToFmFld.htm for a workaround for that if you need it. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org William Bartusek wrote: I can add a bookmark for a text field on a Word document using the following code: ActiveDocument.FormFields(amtIndex).Range.Bookmark s.Add _ Name:=str, _ Range:=ActiveDocument.FormFields(amtIndex).Range Note: "amtIndex" is a defined integer However, I can't figure out the code syntax to use that actually enters the bookmark text in the "Bookmark:" field in the Text Form Field Options dialog form. "Name" doesn't work. The other fields, such as TextInput for "Default number", in the Text Form Field Options dialog have obvious choices as VBA code objects/data members. |
#3
|
|||
|
|||
Setting "Bookmark" text in Text Form Field Options dialog
When I used the code with .Name=str I kept getting an
error message "Method 'Name' of object 'FormField' failed", evidently because of the "odd situation you can encounter in which the fields don't have a name, and then VBA has trouble assigning one." Using VBA I was copying then pasting a FormField to create a duplicate--therefore, the pasted FormField did not have a name. -----Original Message----- Hi William, The form field already has a bookmark associated with it, so you don't need to add one. The one you're adding is "on top of" the field, not the one whose name is shown in the Properties dialog. To change the name of the associated bookmark, use syntax like ActiveDocument.FormFields(amtIndex).Name = str There's an odd situation you can encounter in which the fields don't have a name, and then VBA has trouble assigning one. See http://word.mvps.org/FAQs/MacrosVBA/...ameToFmFld.htm for a workaround for that if you need it. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org William Bartusek wrote: I can add a bookmark for a text field on a Word document using the following code: ActiveDocument.FormFields(amtIndex).Range.Bookmark s.Add _ Name:=str, _ Range:=ActiveDocument.FormFields(amtIndex).Range Note: "amtIndex" is a defined integer However, I can't figure out the code syntax to use that actually enters the bookmark text in the "Bookmark:" field in the Text Form Field Options dialog form. "Name" doesn't work. The other fields, such as TextInput for "Default number", in the Text Form Field Options dialog have obvious choices as VBA code objects/data members. . |
Thread Tools | |
Display Modes | |
|
|