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 / August 2007

Tip: Looking for answers? Try searching our database.

view and reselect currently selected bookmarked form field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
OTWarrior - 16 Aug 2007 13:56 GMT
i have a series of drop down boxes that with have code to add items to their
list (see my other thread for details if you are insterested,
http://www.officekb.com/Uwe/Forum.aspx/word-program/958/form-field-drop-down-25-
limit-list-I-have-made-a-fix-of-sorts#76c655d6f15bfuwe

) and due to the volume of form field (28 will be needed in my case) I wanted
to dynamically change the "Dropdown1" reference in my code to the currently
selected items bookmark name,  for example:

code currently is:
If ActiveDocument.FormFields("Dropdown1").Result = Data2(UBound(Data2)) Then
   ActiveDocument.FormFields("Dropdown1").DropDown.ListEntries.Clear
   ActiveDocument.FormFields("Dropdown1").DropDown.ListEntries.Add "Please
Select..."
       For i = LBound(Data) To UBound(Data)
           ActiveDocument.FormFields("Dropdown1").DropDown.ListEntries.Add
Data(i)
       Next i
end if

code need to be along the lines of:

dim nameSel as string
nameSel = selection.bookmarks.name

If ActiveDocument.FormFields(nameSel).Result = Data2(UBound(Data2)) Then
   ActiveDocument.FormFields(nameSel).DropDown.ListEntries.Clear
   ActiveDocument.FormFields(nameSel).DropDown.ListEntries.Add "Please
Select..."
       For i = LBound(Data) To UBound(Data)
           ActiveDocument.FormFields(nameSel).DropDown.ListEntries.Add Data
(i)
       Next i
end if

I am unable to use the count or index functions for this as it needs to be
the item currently selected, not a "for next" loop, as somene could select
Dropdown1, then Dropdown8.

any advice on how to view the currently selected bookmark name from a form
field would be greatly received.
Jay Freedman - 16 Aug 2007 14:56 GMT
If your form has only dropdowns, or if your macro is an exit macro assigned
only to dropdowns, then you can use the expression

  Selection.FormFields(1).Name

Unfortunately, because of a longstanding bug in VBA, this doesn't work for
text form fields; if you need that, too, see
http://word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm for a workaround.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> i have a series of drop down boxes that with have code to add items
> to their list (see my other thread for details if you are insterested,
[quoted text clipped - 35 lines]
> any advice on how to view the currently selected bookmark name from a
> form field would be greatly received.
OTWarrior - 16 Aug 2007 16:02 GMT
the link was perfect, thanks :)
 
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.