I have a macro that sets the page background to a soft color. To my knowledge their is no way to set that as a document default.I'm pretty sure I saw code somewhere that indicated it was possible to run a macro anytime file was created or opened. Can anyone point me to sample code for that purpose?
You can do that in the "ThisMacroStorage" part of a VBA project with code such as this:
1 2 3 4 5 6 7 8 9
Private Sub GlobalMacroStorage_DocumentNew(ByVal Doc As Document, ByVal FromTemplate As Boolean, ByVal Template As String, ByVal IncludeGraphics As Boolean) ActiveDocument.MasterPage.Layers("Desktop").Editable = False End Sub Private Sub GlobalMacroStorage_DocumentOpen(ByVal Doc As Document, ByVal FileName As String) ActiveDocument.MasterPage.Layers("Desktop").Editable = False End Sub
.
In those examples, I have the code right there, because it's only one line to lock the Desktop layer - but one can also call a public sub that exists elsewhere in that VBA project.
Thanks kindly; works great!
Glad to hear it!
That can also be a convenient place to set some piece of metadata that you always want in your document, e.g., specifying an author name that is different than what will otherwise automatically be inserted:
1
ActiveDocument.Metadata.Author = "Arvide Abernathy"
Neat! I've applied a few of the MetaData items just so I'll remember I can do that.