Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active X command button in Word 2003 protected form

Status
Not open for further replies.

JudyL

Instructor
Feb 21, 2001
148
US
I tried to create a Word template that has some protected sections. I put an Active X command button in an unprotected section. I added some code to the command button. The code for the command button works fine when I open the template directly and click on the button. I can click on it multiple times and it works fine each time (it inserts some Autotext).

If I create a document based on the template, the button works the first time I click on it but not after that.

any ideas?
 
any ideas?
Without seeing the code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top