sabretooth80
Programmer
Hi,
I have some word templates that users can access using a link on the intranet. When they click save, the document needs to be saved in a predefined location on a mapped network drive.
I have created a word template that is opened in a new word instance from a web page using vbscript. When the template opens, the code in the autoOpen runs to create a new document based on the template (I am using vbscript to open the template because the macros to save the document in the predefined location don't run if i just link to the template. Using vbscript to open the template opens the actual template rather than a new document based on the template so that's why i have written some code to open a new document based on the template)
I have put in some code in the FileSave method to ensure that the file gets saved using the predefined name.
All this runs fine. The problem is that when I try to quit word, it asks me if I want to save changes to the template. I don't understand why it is asking me this since I don't think I haven't made any changes to the template, I've only changed the document based on the template. Can I suppress alerts somehow? (displayalerts = false didn't work). Or is there some other way of ensuring that the template isn't changed?
thanks,
sabretooth
code:
Sub AutoOpen()
' Check if document is template, then create new document
If ActiveDocument.Type = wdTypeTemplate Then
sTemplateName = ActiveDocument.FullName
Documents.Add Template:= _
sTemplateName, NewTemplate:=False, DocumentType:=0
Documents(sTemplateName).Close SaveChanges:=wdDoNotSaveChanges
End If
End Sub
Sub FileSave()
If ActiveDocument.Path = "" Then
ActiveDocument.SaveAs FileName:=sFileName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=True, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Else
ActiveDocument.Save
End If
End Sub
I have some word templates that users can access using a link on the intranet. When they click save, the document needs to be saved in a predefined location on a mapped network drive.
I have created a word template that is opened in a new word instance from a web page using vbscript. When the template opens, the code in the autoOpen runs to create a new document based on the template (I am using vbscript to open the template because the macros to save the document in the predefined location don't run if i just link to the template. Using vbscript to open the template opens the actual template rather than a new document based on the template so that's why i have written some code to open a new document based on the template)
I have put in some code in the FileSave method to ensure that the file gets saved using the predefined name.
All this runs fine. The problem is that when I try to quit word, it asks me if I want to save changes to the template. I don't understand why it is asking me this since I don't think I haven't made any changes to the template, I've only changed the document based on the template. Can I suppress alerts somehow? (displayalerts = false didn't work). Or is there some other way of ensuring that the template isn't changed?
thanks,
sabretooth
code:
Sub AutoOpen()
' Check if document is template, then create new document
If ActiveDocument.Type = wdTypeTemplate Then
sTemplateName = ActiveDocument.FullName
Documents.Add Template:= _
sTemplateName, NewTemplate:=False, DocumentType:=0
Documents(sTemplateName).Close SaveChanges:=wdDoNotSaveChanges
End If
End Sub
Sub FileSave()
If ActiveDocument.Path = "" Then
ActiveDocument.SaveAs FileName:=sFileName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=True, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Else
ActiveDocument.Save
End If
End Sub