+ Reply to Thread
Results 1 to 2 of 2

How to diasble save and save as menu but allow a save button

  1. #1
    hon123456
    Guest

    How to diasble save and save as menu but allow a save button

    Dear all,

    I have put a command button which do the save function as follows:

    Private Sub CommandButton1_Click()

    ThisWorkbook.SaveAs Filename:="abc.xls"
    End Sub

    And I have disabled the save and save as menu with following code:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,
    Cancel As Boolean)
    Cancel = True
    End Sub

    Now, the problem is although I can disable the save and save as
    menu, the save button is disabled too. How can I disable save and save
    as menu but still allow my save button(CommandButton1) to save?

    Thanks


  2. #2
    Bob Phillips
    Guest

    Re: How to diasble save and save as menu but allow a save button

    Create a global variable, say SaveOK as a boolean, and in the code add

    Private Sub CommandButton1_Click()
    SaveOK = True
    ThisWorkbook.SaveAs Filename:="abc.xls"
    End Sub


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


    --
    HTH

    Bob Phillips

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

    "hon123456" <[email protected]> wrote in message
    news:[email protected]...
    > Dear all,
    >
    > I have put a command button which do the save function as follows:
    >
    > Private Sub CommandButton1_Click()
    >
    > ThisWorkbook.SaveAs Filename:="abc.xls"
    > End Sub
    >
    > And I have disabled the save and save as menu with following code:
    >
    > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,
    > Cancel As Boolean)
    > Cancel = True
    > End Sub
    >
    > Now, the problem is although I can disable the save and save as
    > menu, the save button is disabled too. How can I disable save and save
    > as menu but still allow my save button(CommandButton1) to save?
    >
    > Thanks
    >




+ 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