• Disabling SAVE, allowing SAVEAS (VBA )

    Author
    Topic
    #375370

    Here’s one that I think is simple, but I can’t find a way to do it.
    I have a MS Word 2000 document that is filled out partially by macros, and the user inserts the rest manually. Is there a way to prevent the user from clicking on the ‘Save’ icon, and forcing them to always use the ‘Save As’? Is it just a matter of making it a template, or is there more to it than that?

    Viewing 4 reply threads
    Author
    Replies
    • #610709

      Well if there are already macros in the document, you can add this macro to the doc:

      Sub FileSave()
      With Application.Dialogs(wdDialogFileSaveAs)
          .Display
          .Execute
      End With
      End Sub
      

      This will “hijack” the File|Save menu item, the CTRL+S and the Save Menu button and always display the SaveAs dialog.

    • #610711

      The easiest way is to save the document as a template, and put it in one of the template folders. If your users are on a network, you can create a network forlder, put the template there, and have users point their Workgroup Templates path (in Tools/Options…, File Locations tab) to this folder. They will see the template when they select File/New…

      An alternative – but more complicated – is to create a macro that replaces the File/Save command:

      Sub FileSave()
      With Dialogs(wdDialogFileSaveAs)
      Select Case .Display
      Case 0 ‘ Cancel
      ‘ No need to do anything on Cancel
      ‘ Unless you want to display a message
      Case -1 ‘ OK
      ‘ Whatever you want to do on OK, for instance
      .Execute
      End Select
      End With
      End Sub

      • #614751

        I think it has been said that making the document a template is the way to go? grin

        If you intercept “Save”, you may need/want to also intercept/redirect other commands to SaveAs:
        FileClose, FileCloseAll, FileCloseOrCloseAll, FileCloseOrExit, FileExit, FileSaveAll, FileSaveAsWebPage, FileSaveFrameAs, FileSaveHtml, FileSaveVersion
        (the Close commands because if you made changes, you will be asked if you want to save).

        A bit nasty are the CloseAll/SaveAll commands, which may run endlessly until all documents are closed/saved unless intercepted properly. But many users won’t know about them anyhow (they appear on the File menu if you hold the Shift key).

        BTW, I haven’t found what Command is run if you click on the close button (

        • #614777

          BTW, I haven’t found what Command is run if you click on the close button (

          • #614795

            I did mean the main Word window

            • #614882

              There is a Document Close button in the first Word Window only.

              I have two main reference for Word’s commands.

              1. Woody’s – Word 97 Annoyances
              2. the macros dialog box (Tools|Macros|Macros… Change Macros In: to Word Commands)

              Sprinkled with a generous helping of trial and error grin

              I haven’t tried intercepting the Help commands, until just now, and I can’t seem to get them to work either.

              I hadn’t heard of that template, but it looks interesting. I just downloaded it.

            • #614996

              My ressources were the same as yours (including “trial and error” wink).

              I append a list of Command names, with differences in my list and Lisa Wollin’s (from override.dot) marked.

              cheers Klaus

    • #610752

      Perfect! Thanks for the quick assist.

    • #610821

      As a footnote to these two posts, a template is much better than a document because it creates a fresh document. Forcing a SaveAs, the user could easily “replace” the document despite having to do it the hard(er) way, by choosing the same name and path (unless you trap for that…complicating your macro). If you need it to be a document rather than a template, making the document read-only in the file system would protect it more simply than a macro, but of course, anyone with privileges to change that setting could do it if they wanted to badly enough.

    • #614720

      This is not foolproof but it will prevent accidentally naming the file the same as your form.

      SaveYN = MsgBox(“Do you want to save the Agreement?”, vbYesNo, “TITLE”)
      If SaveYN = vbYes Then
      With Dialogs(wdDialogFileSaveAs)
      .Name = “DifferentName ”
      .Show
      End With
      End If

    Viewing 4 reply threads
    Reply To: Disabling SAVE, allowing SAVEAS (VBA )

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: