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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disbling Macros in doc based on Temp

Status
Not open for further replies.

VBAnewguy

MIS
Jan 28, 2003
41
US
Hey, new to the forum, I will make this quite, I would appreciate any help you guys could give.

I have a template that autocreates a document based on itself upon opening. The template contains some forms and document automation that are usefull when creating the new document.

Here is the problem: After the doc in initially created and saved, I need to be able to disable the macros (perminetaly if possible) on the doc. The docs will be used by end users that will not understand the "enable/disable macros" on these docs.

Is there a way to code an if/then to ask something like below, I do not know the right objects/properties to use:

OnOpen
If active.document TYPE = .doc then
end
else proceed to Module X

I dont know how to get this into VBA correctly, thanks,
 
When a Word template contains macros, the documents created from it typically don't receive these macros - instead, the template is loaded every time the document is loaded. Try using:

With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = ""
End With

before you save the document that was based on the template. That way, the template won't open next time it's opened, and there will be no macros to worry about.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top