Populate drop down with text from bookmarks in Word VBA 
Author Message
 Populate drop down with text from bookmarks in Word VBA

I'm trying to create a macro to be used 'on exit' from a drop down where the user selects their work scheme, and the drop down for the employees is populated from bookmarked text entries depending on what scheme they selct. The text is just that, text which has been bookmarked.
'namedd' is the drop down to be populated, 'callsigndd' is the drop down where they first select their work scheme; the bookmarks Camberwell1 through to Camberwell16 are the bookmarks from which I want the entries in the 'namedd' to be populated. It doesn't work though and gives an error message that the object does not exist, even though it does (the drop downs). So far I have the following:

Sub populatename()
ActiveDocument.FormFields("nameDD").DropDown.ListEntries.Clear
Select Case ActiveDocument.FormFields("callsigndd").Result

    Case "C (Camberwell)"
        Selection.FormFields("nameDD").DropDown.ListEntries.Clear
    Selection.FormFields("namedd").DropDown.ListEntries.Add Name:= _
        ActiveDocument.Bookmarks("Camberwell1").Range.Text

    Selection.FormFields("nameDD").DropDown.ListEntries.Add Name:= _
        ActiveDocument.Bookmarks("Camberwell2").Range.Text

Selection.FormFields("nameDD").DropDown.ListEntries.Add Name:= _
        ActiveDocument.Bookmarks("Camberwell3").Range.Text

Selection.FormFields("nameDD").DropDown.ListEntries.Add Name:= _
        ActiveDocument.Bookmarks("Camberwell4").Range.Text

Selection.FormFields("nameDD").DropDown.ListEntries.Add Name:= _
        ActiveDocument.Bookmarks("Camberwell5").Range.Text

Selection.FormFields("nameDD").DropDown.ListEntries.Add Name:= _
        ActiveDocument.Bookmarks("Camberwell6").Range.Text

        End Select
       End Sub

---
frmsrcurl: http://www.*-*-*.com/



Sat, 15 Dec 2012 05:32:06 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VBA code to go to a bookmarked drop down goes to wrong drop down

2. Populating a drop down menu with delimited text

3. replacing bookmark text in vba: bookmark deleted ?

4. populate drop down?????

5. Drop Down populated from a datareader problem.

6. Populating drop down boxes with SQL data

7. populate drop down box

8. Populate an IE drop-down list programmatically

9. Populating a drop down list

10. populating a drop down menu

11. Populating Drop Down Lists

12. Dynamically populate drop down list box using webclasses

 

 
Powered by phpBB® Forum Software