Sub AutoExecUnloadGlobal()
' Written 1 April 2002 by Charles Kenyon
' Automatically unloads this global template
' Put in AutoExec procedure
'
MsgBox prompt:="Sorry, " & ThisDocument.Name _
& " cannot act as a global template.", _
Title:=ThisDocument.Name & " improperly loaded", _
Buttons:=vbExclamation
AddIns(ThisDocument.FullName).Installed = False
End Sub
ThisDocument.SaveAs FileName:=sDocFullPathNew, FileFormat:= _
wdFormatTemplate, LockComments:=False, Password:="",
AddToRecentFiles:= _
False, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
MsgBox _
prompt:="This template has been saved in the directory:" _
& vbCrLf & Word.Options.DefaultFilePath(wdUserTemplatesPath) _
& vbCrLf & "as " & ThisDocument.Name & ".", _
Title:="Template save completed!"
Sub TemplatesPathIsMacro()
'
' TemplatesPathIsMacro Macro
' Macro written 3 December 2001 by Charles Kyle Kenyon
'
Dim sUserTemplatesLocation As String
Dim sWorkgroupTemplatesLocation As String
Dim sStartUpTemplatesLocation As String
'
sUserTemplatesLocation = Options.DefaultFilePath(wdUserTemplatesPath) &
"\"
sWorkgroupTemplatesLocation =
Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\"
sStartUpTemplatesLocation = Options.DefaultFilePath(wdStartupPath) & "\"
'
MsgBox prompt:="The user templates are in:" & vbCrLf _
& sUserTemplatesLocation & vbCrLf & vbCrLf _
& "The Workgroup Templates are in:" & vbCrLf _
& sWorkgroupTemplatesLocation & vbCrLf & vbCrLf _
& "The Startup (Add-In) Templates are in:" & vbCrLf _
& sStartUpTemplatesLocation, _
Title:="Templates location settings"
End Sub
Private Sub LockUnlockFormToggleV()
' Toggle macro to protect / unprotect form
' Written by Charles Kenyon
Dim oDoc As Document
Set oDoc = ActiveDocument
If oDoc.ProtectionType <> wdNoProtection Then
oDoc.Unprotect
Else
If oDoc.ProtectionType = wdNoProtection Then
oDoc.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True
End If
End If
End Sub
Private Sub DetachDoc()
' Written by Charles Kyle Kenyon on December 1, 2003
'
Dim sTemplatesPath As String
sTemplatesPath =
Application.Options.DefaultFilePath(wdUserTemplatesPath)
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
sTemplatesPath & "\Normal.dot"
End With
End Sub
Above are some code snippets using named parameters. Otherwise, you list
your parameters, separated by commas, in order. This makes code (somewhat)
easier to read.
--
Charles Kenyon
Word New User FAQ & Web Directory:
http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
http://addbalance.com/usersguide
See also the MVP FAQ:
http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.