Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have a cmdbutton that I would like to use to close a workbook. think I'm placing the procedures in the wrong area. Honestly, I'm no sure how to set it up. The reason I say that is because I have a custo menu with some code in Workbook_BeforeClose that duplicates excels sav dialog box to stop the custom menu from being deleted if the user clic on cancel. I have tried putting a call commandbutton_click() in th Workbook_BeforeClose but, I get an error. In th commandbutton_click(), I used Workbooks("MyFile.XLS").Close. Is thi the right method or am I missing something? Can you even call commandbutton? I guess that defeats the whole purpose of commandbutton. Here is the code I have: Private Sub Workbook_BeforeClose(Cancel As Boolean) ' If possible, what method would I use to call the cmdbutton? If Not Me.Saved Then Dim Msg As String Dim Ans As Integer Beep Msg = "Do you want to save the changes you made to " Msg = Msg & Me.Name & "?" Ans = MsgBox(Msg, vbQuestion + vbYesNoCancel) Select Case Ans Case vbYes Me.Save Case vbNo Me.Saved = True Case vbCancel Cancel = True Exit Sub End Select End If Call DeleteMenu End Sub Rockee Excel 200 -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CommandButton to open a Excel workbook | Excel Discussion (Misc queries) | |||
workbook before close | Excel Discussion (Misc queries) | |||
close only one workbook | New Users to Excel | |||
How can I close only 1 workbook when I have many open? | Excel Discussion (Misc queries) | |||
cannot close workbook | Excel Programming |