Just wondering why Active X controls would only work once in a document based on a template that has two sections locked. The section containing the ActiveX control, a command button, is not in the locked section. If, I open the template, the button works multiple times but when I used a document based on the template, it does not.
Here is the code
Private Sub AddCompetency_Click()
' InsertText Macro - This macro inserts a competency autotext
'
ActiveDocument.Unprotect
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Performance Planning and Review Form"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=2 ' Moves the cursor just above the page break
Selection.TypeParagraph
' The value of the dropdown corresponds to the location of the value selected in the dropdown list.
If ActiveDocument.FormFields("Competencies").DropDown.Value = 5 Then
ActiveDocument.AttachedTemplate.AutoTextEntries("Influencing").Insert _
Where:=Selection.Range, RichText:=True
End If
ActiveDocument.Sections(1).ProtectedForForms = True
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.Sections(3).ProtectedForForms = True
ActiveDocument.Sections(4).ProtectedForForms = False
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
Selection.GoTo What:=wdGoToBookmark, Name:="Influencing"
End Sub