From: johnnykunst on
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://msgroups.net/microsoft.public.vb.general.discussion
From: Paul Clement on
On Tue, 06 Jul 2010 00:06:04 -0700, johnnykunst <user(a)msgroups.net/> wrote:

� 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)