PC Review


Reply
Thread Tools Rate Thread

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

 
 
hon123456
Guest
Posts: n/a
 
      12th Jun 2006
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      12th Jun 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save/Save As Menu Options Don't Save Document erik_gregory Microsoft Word Document Management 0 14th Jul 2008 10:21 PM
SAVE and SAVE AS options disappeared from the drop down FILE menu baltus.leroux@resbank.co.za Microsoft Excel Misc 2 12th Jul 2007 09:14 AM
Disable save, save as, but allow save via command button =?Utf-8?B?VGltTg==?= Microsoft Excel Programming 10 1st Sep 2006 07:05 PM
Word 2002 save as menu says save as web page instead of just save as? Gary Microsoft Word Document Management 1 28th Jul 2006 03:26 PM
Adding items to menu bar on left side of 'save' or 'save as' menu =?Utf-8?B?TWF0dGhld1RhcA==?= Windows XP General 2 2nd Dec 2005 12:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:06 AM.