VBA code to go to a bookmarked drop down goes to wrong drop down 
Author Message
 VBA code to go to a bookmarked drop down goes to wrong drop down

I am using VBA code to perfprm a variety of tasks; the code is working fine, except, the last action before re protecting the form is to go to a specific bookmarked drop down 'byelaw1' but it goes to 'byelaw2' instead:

Sub Onexitclassification()

If ActiveDocument.FormFields("pclassificationDD").Result = "CASB(B)/ Offences against park byelaws" Then
ActiveDocument.FormFields("Classificationtext").Result = "(In accordance with the LBS 'Byelaws for Pleasure Grounds, Public Walks and Open Spaces' November 2008)"

ActiveDocument.Unprotect
   Selection.GoTo What:=wdGoToBookmark, Name:="byelawsection"
    With ActiveDocument.Bookmarks
        .DefaultSorting = wdSortByName
        .ShowHidden = False
    End With
    With Selection.Font
        .Name = "Arial"
        .Size = 10
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .Animation = wdAnimationNone

Selection.GoTo What:=wdGoToBookmark, Name:="byelaw1"
    With ActiveDocument.Bookmarks
        .DefaultSorting = wdSortByName
        .ShowHidden = False
    End With

ActiveDocument.Protect wdAllowOnlyFormFields, NoReset

End With

End If

End Sub

I've tried to work out the problem by elimination and have stripped the code right down to:

Sub Onexitclassification ()
Selection.GoTo What:=wdGoToBookmark, Name:="byelaw1"
End Sub

The same problem happens. This is even with all other macro's in the form deleted, and all other bookmarks deleted, and I've even tried giving the drop downs & macro new names!

The macro is an 'on exit' macro run from another form drop down.

Any help would be greatly appreciated

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



Sat, 22 Dec 2012 15:06:04 GMT  
 VBA code to go to a bookmarked drop down goes to wrong drop down

I am using vba code to perfprm a variety of tasks; the code is working fine, except, the last action before re protecting the form is to go to a specific bookmarked drop down 'byelaw1' but it goes to 'byelaw2' instead:

Sub Onexitclassification()


If ActiveDocument.FormFields("pclassificationDD").Result = "CASB(B)/ Offences against park byelaws" Then
ActiveDocument.FormFields("Classificationtext").Result = "(In accordance with the LBS 'Byelaws for Pleasure Grounds, Public Walks and Open Spaces' November 2008)"

I would recommend posting your question to the Word for Developers forum:

http://social.msdn.microsoft.com/Forums/en-US/worddev/threads

Paul
~~~~
Microsoft MVP (Visual Basic)



Sat, 22 Dec 2012 21:12:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Drop Down List Box - Drop Down portion does not always disappear after Click event

2. Press F1 key while drop-down menu item highlighted, drop-down menu stays on top

3. Data bound drops downs dont drop down!

4. VBA Code for Defining Drop Down List

5. drop down box and down arrow key

6. Drop Down Combo box with smaller down arrow icon

7. Table Layout and Drop down (vba to javascript)

8. Populate drop down with text from bookmarks in Word VBA

9. How come my code drop downs are incomplete

10. Code to drop down list on userform

11. Making a combo Box Drop Down via code

12. Dropping down a DTPicker Control with Code

 

 
Powered by phpBB® Forum Software