Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    Atlanta, Georgia, USA
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disabling SAVE, allowing SAVEAS (VBA )

    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?

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    Well if there are already macros in the document, you can add this macro to the doc:
    <pre>Sub FileSave()
    With Application.Dialogs(wdDialogFileSaveAs)
    .Display
    .Execute
    End With
    End Sub
    </pre>


    This will "hijack" the File|Save menu item, the CTRL+S and the Save Menu button and always display the SaveAs dialog.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    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

  4. #4
    Star Lounger
    Join Date
    Mar 2001
    Location
    Atlanta, Georgia, USA
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    Perfect! Thanks for the quick assist.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    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.

  6. #6
    Lounger
    Join Date
    Aug 2002
    Location
    Oklahoma City, Oklahoma, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    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

  7. #7
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    I think it has been said that making the document a template is the way to go? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    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 (

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    <blockquote><hr>BTW, I haven't found what Command is run if you click on the close button (
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  9. #9
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    I did mean the main Word window

  10. #10
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

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

    I have two main reference for Word's commands.
    1. <LI>Woody's - Word 97 Annoyances
      <LI>the macros dialog box (Tools|Macros|Macros... Change Macros In: to Word Commands)
    Sprinkled with a generous helping of trial and error <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    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.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  11. #11
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling SAVE, allowing SAVEAS (VBA )

    My ressources were the same as yours (including "trial and error" <img src=/S/wink.gif border=0 alt=wink width=15 height=15>).

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

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •