Help with 2007 macro template

E

EKH

I’m pretty new to this, but I’ve created a .docm template with some
automation in 2007. The template contains activeX checkboxes and code for
click events. All works fine in the template but not in documents created
from the template. The template is saved to a trusted location. The other
strange thing is that the code works for a single click event regardless of
which checkbox is clicked and then stops running. I’m also using combo boxes
in the template with the same problem. The list items populate in the
template, but not in docs based on the template.

I’ve included the checkbox code from the template. Any help will be greatly
appreciated.

Public Sub OptGenExemptHide_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString

With ActiveDocument
If ActiveDocument.Bookmarks.Exists("generalexemptions") = True Then
Msg = "This action will remove the General Exemptions checklist and changes
" & _
"made to it. Click OK to continue. Click Cancel to return to the
checklist."
Style = vbOKCancel + vbDefaultButton1
Title = "Remove Checklist"
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
ActiveDocument.Bookmarks("generalexemptions").Select
Selection.Delete
OptGenExemptHide.Value = False
End If
Else
MsgBox "This checklist cannot be found."
OptGenExemptHide.Value = False
End If
End With
End Sub

Public Sub OptGenExemptView_Click()
With ActiveDocument
Selection.Move wdParagraph
'Selection.TypeParagraph
Selection.TypeText "exemption "
Selection.Range.InsertAutoText
'Selection.GoTo What:=wdGoToPage, Count:=2
End With
End Sub

Public Sub OptIdentHide1_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString

If ActiveDocument.Bookmarks.Exists("identification") = True Then
Msg = "This action will remove the General Exemptions checklist and changes
" & _
"made to it. Click OK to continue. Click Cancel to return to the
checklist."
Style = vbOKCancel + vbDefaultButton1
Title = "Remove Checklist"
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
ActiveDocument.Bookmarks("identification").Select
Selection.Delete
OptIdentHide1.Value = False
End If

Else
MsgBox "This checklist cannot be found."
OptIdentHide1.Value = False

End If
End Sub
 
E

EKH

Correction to my original post. The code resides in a dotm not a docm.
Although, I've saved this as a docm and the automation still works. I now
understand that the problem is that the code must reside in a macro enabled
document.

What I need to figure out, is how to force word to create a docm file based
on a dotm. For example, if I create a document based on a dotm. template and
save the file as a docm, some of the code seems to get disabled in the
process. If I open the the dotm and save as a docm all is fine. Is it
possible to force Word to create a docm file based on a dotm?
 
D

Doug Robbins - Word MVP

If the template is a dotm and you use File>New to create a document from
that template, then if the document is later opened on the machine on which
it was created, a reference to the dotm will be created and the macros in
the dotm will be available for use in the document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top