+ Reply to Thread
Results 1 to 8 of 8

Disabling SaveAs and Save?

  1. #1
    Registered User
    Join Date
    06-14-2004
    Posts
    75

    Question Disabling SaveAs and Save?

    Hiya guys!

    I am looking for a way to disable SaveAs and Save in the File drop down menu as well as the prompt on Close event...

    I have been rumaging around on the web without success...

    Many thanks!

    J

  2. #2
    Bob Phillips
    Guest

    Re: Disabling SaveAs and Save?

    If you add this code

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
    Boolean)
    If Not fSave Then
    Cancel = True
    End If
    End Sub

    'This is workbook event code.
    'To input this code, right click on the Excel icon on the worksheet
    '(or next to the File menu if you maximise your workbooks),
    'select View Code from the menu, and paste the code

    all saving should be disabled for that workbook. I have tested for fSave,
    which if you create as a Public variable in a standard code module, you can
    set that in your code and then save it. Remember to set back to false
    aftwerwards.

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Petitboeuf" <Petitboeuf.2aipxn_1152179702.2987@excelforum-nospam.com> wrote
    in message news:Petitboeuf.2aipxn_1152179702.2987@excelforum-nospam.com...
    >
    > Hiya guys!
    >
    > I am looking for a way to disable SaveAs and Save in the File drop down
    > menu as well as the prompt on Close event...
    >
    > I have been rumaging around on the web without success...
    >
    > Many thanks!
    >
    > J
    >
    >
    > --
    > Petitboeuf
    > ------------------------------------------------------------------------
    > Petitboeuf's Profile:

    http://www.excelforum.com/member.php...o&userid=10602
    > View this thread: http://www.excelforum.com/showthread...hreadid=558792
    >




  3. #3
    Registered User
    Join Date
    06-14-2004
    Posts
    75
    Bob

    Thank you very much! It does work!!

    Well... so much so that... how do i save my workbook with the module in AFTER pasting it?!

  4. #4
    Bob Phillips
    Guest

    Re: Disabling SaveAs and Save?

    As I mentioned, I added a variable to allow you to do that through code.

    In a standard code module, declare the variable at the start

    Public fSave As Boolean

    Then add a simple save macro

    Sub Private SaveMyWB()

    fSave = True
    ThisWorkbOkk.SaveAs "myFilename.xls" '<==== Change to suit
    fSave = False

    End Sub

    I made it private so that it doesn't show in the list of macros from Excel.
    Run it from the VBIDE by setting the cursor within the macro and the F5, or
    call it in the immediate window.
    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Petitboeuf" <Petitboeuf.2aispn_1152183302.3181@excelforum-nospam.com> wrote
    in message news:Petitboeuf.2aispn_1152183302.3181@excelforum-nospam.com...
    >
    > Bob
    >
    > Thank you very much! It does work!!
    >
    > Well... so much so that... how do i save my workbook with the module in
    > AFTER pasting it?!
    >
    >
    > --
    > Petitboeuf
    > ------------------------------------------------------------------------
    > Petitboeuf's Profile:

    http://www.excelforum.com/member.php...o&userid=10602
    > View this thread: http://www.excelforum.com/showthread...hreadid=558792
    >




  5. #5
    Registered User
    Join Date
    06-14-2004
    Posts
    75
    Bob

    I am so sorry to bother you again but... well I'm no expert and still trying real hard to understand that VB thingy

    So far i have done the following:

    1. in the ThisWorkbook code in General I have the Private Sub Workbook_BeforeSave pasted

    2. in the same location I have the Public Sub SaveMyWB pasted

    3. I do not know where to put the Public fSave As Boolean as it doesn't seem to stand alone...


    Damn it's hard to be thick!

  6. #6
    Bob Phillips
    Guest

    Re: Disabling SaveAs and Save?

    Put 2 and 3 in a standard code module (Insert>Module)

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Petitboeuf" <Petitboeuf.2aiyyo_1152191407.235@excelforum-nospam.com> wrote
    in message news:Petitboeuf.2aiyyo_1152191407.235@excelforum-nospam.com...
    >
    > Bob
    >
    > I am so sorry to bother you again but... well I'm no expert and still
    > trying real hard to understand that VB thingy
    >
    > So far i have done the following:
    >
    > 1. in the ThisWorkbook code in General I have the Private Sub
    > Workbook_BeforeSave pasted
    >
    > 2. in the same location I have the Public Sub SaveMyWB pasted
    >
    > 3. I do not know where to put the Public fSave As Boolean as it doesn't
    > seem to stand alone...
    >
    >
    > Damn it's hard to be thick!
    >
    >
    > --
    > Petitboeuf
    > ------------------------------------------------------------------------
    > Petitboeuf's Profile:

    http://www.excelforum.com/member.php...o&userid=10602
    > View this thread: http://www.excelforum.com/showthread...hreadid=558792
    >




  7. #7
    Registered User
    Join Date
    06-14-2004
    Posts
    75
    Thank you very much.

    Out of interest why does it work if in a Module instead of on a sheet?

  8. #8
    Bob Phillips
    Guest

    Re: Disabling SaveAs and Save?

    It probably would if you put everything in the worksheet module, including
    the Public variable, but you would not be able to call it from the Excel
    macro list.

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Petitboeuf" <Petitboeuf.2aizvz_1152192602.4698@excelforum-nospam.com> wrote
    in message news:Petitboeuf.2aizvz_1152192602.4698@excelforum-nospam.com...
    >
    > Thank you very much.
    >
    > Out of interest why does it work if in a Module instead of on a sheet?
    >
    >
    > --
    > Petitboeuf
    > ------------------------------------------------------------------------
    > Petitboeuf's Profile:

    http://www.excelforum.com/member.php...o&userid=10602
    > View this thread: http://www.excelforum.com/showthread...hreadid=558792
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1