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!

disable 'save as'

Status
Not open for further replies.

sabretooth80

Programmer
Joined
May 5, 2003
Messages
2
Location
AU
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
 
Hi
Word aint my thang & I haven't tested this properly but would
Code:
Private Sub Document_Close()
Me.Saved = True
End Sub
In the template do the trick?

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
The code you suggested didn't stop the prompt asking whether the i wished the template to be saved.

I think I worked out why the program was prompting me to save the template. I had some code to disable the "save as":

Private Sub Document_Close()
Application.CommandBars("Menu Bar") _
.Controls("&File").Controls("Save &as...").Enabled = True
Me.Saved = True
End Sub

Private Sub Document_Open()
Application.CommandBars("Menu Bar") _
.Controls("&File").Controls("Save &as...").Enabled = False
End Sub

and maybe that caused the template to change.

I got rid of that code and put in a sub filesaveas() which calls filesave so the user is still prevented from putting in their own filename. I would still prefer to find a way to prevent the user from being prompted to save the template as this solution is not as user-friendly as the user will wonder why they're not getting a dialog box prompting for the file name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top