Results 1 to 14 of 14
  1. #1
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable Save/SaveAs (Office 2000)

    Is it possible to disable the Save and SaveAs commands so that a Word or Excel file may not be saved in any form? Our company puts templates for evaluation and salary determination on the network. HR does not want completed individual employee files saved on the computers where the evaluation takes place or on the network, so it is necessary to prevent saving in any form, including using Save As and renaming. We send the completed files to HR to be printed. We are using Windows NT and Office 2000, and I am willing to try anything to fix this problem.

  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: Disable Save/SaveAs (Office 2000)

    Have a look at <!post=this thread, 171195>this thread<!/post>.

    It should give you what you need, or at least a good start.
    --
    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
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    Almost, but I don't want the SaveAs option to be available either. The user should not be able to save the document in any form at all.

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

    Re: Disable Save/SaveAs (Office 2000)

    This will hijack the Save As command.

    Sub FileSaveAs()
    MsgBox "Saving of this file is not allowed"
    End Sub
    --
    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

  5. #5
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    Does this work for Excel as well? I tried it, and it didn't work, but that is probably due to my inexperience with VBA. Can you help me further? I put it in as a macro in module 1 in the following form:

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

    Sub FileSaveAs()
    MsgBox "Saving of this file is not allowed"
    End Sub

    I am sure there is more to it than that, especially since it didn't work.
    Thanks for your help

  6. #6
    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: Disable Save/SaveAs (Office 2000)

    You can't stop a determined user from doing anything. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> But I gather you are trying to make it just hard enough that the other 98% simply print the document and route it to HR.

    Some thoughts:
    1. <LI>Replace the Save and Save As commands. Bryan's syntax works in Word. In Excel, you might need to capture the command using an event procedure. This is beyond the scope of a quick lunch hour post, but you can find examples throughout the Lounge of how to create an event procedure and determine the Command ID for the event.

      <LI>Customize toolbars and menus. You can place code in the form or its corresponding template that will remove the Save and Save As menu items and the Save button from the menus and toolbars for the relevant document only. This is not 100% reliable, though, so I certainly would not rely on that alone. Maybe it's better not to, because users might search out other options, like Save As HTML or Send To (to blast it into e-mail), which would create their own problems. I guess you'd have to remove those as well.
    Might have to just give out paper in the first place!

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

    Re: Disable Save/SaveAs (Office 2000)

    I thought it would, but it appears it doesn't.

    In Word, though you will need to change the FileSave to this:

    Sub FileSave()
    MsgBox "Saving of this file is not allowed"
    End Sub
    --
    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

  8. #8
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Appleton, Wisconsin, USA
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    Another option might be to go to PDF with this type of document. Have HR post the documents to this format using Adobe Acrobat and they can set whether users can modify/print the document fairly painlessly. I don't know what your needs are, but Adobe Acrobat does have a (somewhat clunky) forms component to it.

  9. #9
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    I had already put the Word documents in .pdf format, but it would be so much better if I could use a Word form and take the data into Excel directly, Thus the questions about Word. BTW, the code works for Word as stated with a simple message:
    Sub FIleSave()
    MsgBox "no"
    End Sub
    Sub FileSaveAs()
    MsgBox "no"
    End Sub

    In Excel, I used the following:
    Private Sub Workbook_BeforeSAve(ByVal SaveAsIU As Boolean, Cancel As Boolean)
    a = MsgBox("You may not save this worksheet. Print Only.", vbOK)
    If a = vbOK Then Cancel = True
    If a = vbCancel Then Cancel = True
    I know the vbCancel is not necessary, but I don't know how to make the Cancel button go away.
    Two observations - Save is still an option when I use the close button to close the worksheet, and it is hard to save the macro when you have disabled save. Does anyone know how to disable the Save on close?

    Thanks for all your help.

  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: Disable Save/SaveAs (Office 2000)

    <hr>I know the vbCancel is not necessary, but I don't know how to make the Cancel button go away.<hr>
    Rose,

    Change this line:
    a = MsgBox("You may not save this worksheet. Print Only.", vbOK)
    to:
    a = MsgBox("You may not save this worksheet. Print Only.", vbOKOnly)

    And easier way is to just use:

    Private Sub Workbook_BeforeSAve(ByVal SaveAsIU As Boolean, Cancel As Boolean)
    'Put amessage box here if you wish, but not necessary
    Cancel = True
    End Sub

    <hr>Two observations - Save is still an option when I use the close button to close the worksheet, and it is hard to save the macro when you have disabled save. Does anyone know how to disable the Save on close?<hr>
    To Disable save on close add this sub in Word

    Sub FileClose()
    ActiveDocument.Close False
    End Sub

    And this sub in Excel

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ActiveWorkbook.Close False
    End Sub

    This won't save any changes made to the document or workbook

    The easiest way to save a document that has the Save(As) disabled is to goto the Immediate Window in the VBE and type:

    ActiveDocument.Save

    ActiveWorkbook.Save

    for Excel
    --
    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
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    Bryan,
    You are a wonderful person! Thank you so much for your help. I am a simple application person and have never had any VBA training. My new job requires it, apparently, and I just had to jump in and try to figure it out. I am forever indebted to you.

  12. #12
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    A small problem still exists...the immediate window idea doesn't work to save. I still get my message that says I can't save. I think the Workbook_BeforeSave being cancelled is all powerful. Could I develop a password request in the routine before Cancel = true that would allow me to bypass the cancel?
    This is all very frustrating. Finally, saving is not possible, but that means I can't save the workbook with the macros. Catch 22 lives on.

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

    Re: Disable Save/SaveAs (Office 2000)

    Well, I was afraid of that. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

    Here is what you can do:

    When you want to save the Workbook open up the VBE (ALT+F11)
    Open the ThisWorkbook module
    Put a Breakpoint on the Cancel = True Line (Move the cursor to the line and hit F9. This will turn the line a brownish colour.
    Go to the Immediate Window and type in the ActiveWorkbook.Save command.
    THe Code will stop on the line that you put the breakpoint on will turn yellow.
    Just Drag the little arrow on the left to the End Sub Line.
    Hit F5
    That will bypass the Cancel = True line.

    I am attachig a picture for you to see what a breakpoint and The yellow arrow I am talking about look like.

    Hopefully all this is clearer than mud <img src=/S/grin.gif border=0 alt=grin width=15 height=15> If not, let me know where I confused you.
    Attached Images Attached Images
    --
    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

  14. #14
    New Lounger
    Join Date
    Sep 2002
    Location
    Bluefield, West Virginia, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Save/SaveAs (Office 2000)

    Believe it or not, I understood it and it worked! Thanks so much. <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    I also developed a little password routine to go into the Workbook BeforeSave cancel:
    Private Sub Workbook_BeforeSave(ByVal SaveAsIU As Boolean, Cancel As Boolean)
    Dim Strpass As String
    Strpass = InputBox("Please enter your password", "Password")
    If Strpass <> "snglrose" Then
    MsgBox "no"
    Cancel = True
    End If
    End Sub
    This allows me to bypass the cancel and save if I know the password. Pretty cool, eh? (Actually I had a little help from someone in the office.) <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>
    Thanks again.

Posting Permissions

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