A
aehan
Hello everyone
I'm having a problem with some code. I have created a template in Word 2003
which includes text that may be edited in the template only. The document
created from it is fully protected allowing no edits. I have created a
message box in the This Document module of the template as follows:
Sub AutoOpen()
Dim Response As String
Response = msgbox("Do you want to open the template to edit it? If so,
press Yes." _
& vbCrLf & "To open a document based on the template press No." _
& vbCrLf & "To exit without opening either, press Cancel", vbYesNoCancel
+ vbDefaultButton2)
If Response = vbYes Then
ThisDocument.Activate
CommandBars("Colours").Visible = True
ElseIf Response = vbNo Then
ThisDocument.Close
Documents.Add Template:= _
"C:\Documents and Settings\UserName\Application
Data\Microsoft\Templates\Test Data\Test Template.dot" _
, NewTemplate:=False, DocumentType:=0
ElseIf Response = vbCancel Then ThisDocument.Close
End If
End Sub
I have written an AutoNew macro in a module in the same project as below:
Sub AutoNew()
' Protect Document
ActiveDocument.Protect Password:="secret", NoReset:=False, Type:= _
wdAllowOnlyFormFields, UseIRM:=False, EnforceStyleLock:=False
CommandBars("Task Pane").Visible = False
CommandBars("Colours").Visible = False
End Sub
Everything appears to work perfectly, except that when a protected document
based on the template is re-opened the message box is displayed! Help! What
have I done wrong? Any help would be gratefully received. I've spent a lot
of time trying to work it out and looking through the help group, but
couldn't find an answer.
Thank you all
Aehan
I'm having a problem with some code. I have created a template in Word 2003
which includes text that may be edited in the template only. The document
created from it is fully protected allowing no edits. I have created a
message box in the This Document module of the template as follows:
Sub AutoOpen()
Dim Response As String
Response = msgbox("Do you want to open the template to edit it? If so,
press Yes." _
& vbCrLf & "To open a document based on the template press No." _
& vbCrLf & "To exit without opening either, press Cancel", vbYesNoCancel
+ vbDefaultButton2)
If Response = vbYes Then
ThisDocument.Activate
CommandBars("Colours").Visible = True
ElseIf Response = vbNo Then
ThisDocument.Close
Documents.Add Template:= _
"C:\Documents and Settings\UserName\Application
Data\Microsoft\Templates\Test Data\Test Template.dot" _
, NewTemplate:=False, DocumentType:=0
ElseIf Response = vbCancel Then ThisDocument.Close
End If
End Sub
I have written an AutoNew macro in a module in the same project as below:
Sub AutoNew()
' Protect Document
ActiveDocument.Protect Password:="secret", NoReset:=False, Type:= _
wdAllowOnlyFormFields, UseIRM:=False, EnforceStyleLock:=False
CommandBars("Task Pane").Visible = False
CommandBars("Colours").Visible = False
End Sub
Everything appears to work perfectly, except that when a protected document
based on the template is re-opened the message box is displayed! Help! What
have I done wrong? Any help would be gratefully received. I've spent a lot
of time trying to work it out and looking through the help group, but
couldn't find an answer.
Thank you all
Aehan