Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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" wrote in message
oups.com...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SAVE and SAVE AS options disappeared from the drop down FILE menu [email protected] Excel Discussion (Misc queries) 2 July 12th 07 09:14 AM
Command Button Save As Application.ExecuteExcel4Macro ("SAVE.AS?() Paul Dennis Excel Discussion (Misc queries) 5 September 18th 06 05:34 PM
how to get disk icon on save button of save as dialog like 2000 RichT Excel Discussion (Misc queries) 2 March 9th 06 08:13 PM
Save & Save As features in file menu of Excel Blue Excel Discussion (Misc queries) 9 December 27th 04 08:49 PM
save button in excel to save one of the worksheets with a cell value as its name Colin[_9_] Excel Programming 2 September 21st 04 11:28 PM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"