LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cancel "Save Workbook" popup

I was only ripping the code off the top of my head, it wasn't meant to be
complete solution <vbg

Also I forgot this would be in ThisWorkbook, so you could use Me.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"RC-" wrote in message
...
It looks like the code you sent originally was just missing the Me.Saved =
True if the user clicked No and Me.Save if the user clicked Yes. The
Me.Saved statement tricks Excel into not prompting to save. Here is the
code that I wrote based on your input:

'Check if the workbook needs to be saved
If ActiveWorkbook.Saved = False Then

'If so, open a dialog box asking to save, not save, or cancel
ans = MsgBox("Do you want to save the changes you made to '" & Me.Name &
"'?", vbYesNoCancel, Me.Parent)

Select Case ans
Case vbCancel: Cancel = True
Case vbYes: Me.Save
Case vbNo: Me.Saved = True
End Select

End If

This works perfectly, thanks for getting me on the right track!

RC-

"Bob Phillips" wrote in message
...
Show me the code that doesn't work.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"RC-" wrote in message
...
Bob, unfortunately, the code still does not do what I'm looking for. I

can
cancel the Workbook_BeforeClose routine, but the Save dialog box still

opens
after that routing is done. I found this


http://msdn2.microsoft.com/microsoft...reclose. aspx
but that doesn't do what I'm looking for either, any other ideas?

Thanks again,
RC


"Bob Phillips" wrote in message
...
A different approach.

Check if the workbook is 'dirty'

If Not Activeworkbook.Saved

and is so throw up your own message

ans = MsgBox ("Save the workbook", vbYesNoCancel)

and test if they cancel

If ans - vbCancel Then

don't remove your commandbar, and Cancel the close

Cancel = True

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"RC-" wrote in message
...
I have some code that runs during the Workbook_BeforeClose

procedure.
I
have a Main Menu menu bar that I want to remove when the user closes

the
workbook.

The code works with out problem, but, if the user is prompted to

save
the
workbook before closing AND Cancel is clicked, the menu is removed

but
the
workbook is still open, the user then does not have access to the

menu
options.

I am trying to figure out a way to invoke code that will rebuild the

menu
bar if the user clicks Cancel at the save workbook dialog box.

Does anyone know how to capture the Cancel event of the save

workbook
procedure?

TIA
RC-












 
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
Protect "Copy" and "Save As" changes to workbook Jason W Excel Discussion (Misc queries) 3 January 4th 09 01:13 AM
Suppress popup "Do you really want to save..." after open and immediate close of excel sheets ? Markus Obermayer Excel Discussion (Misc queries) 2 January 2nd 07 02:12 PM
Suppress popup "Do you really want to save..." after open and immediate close of excel sheets ? Markus Obermayer Excel Worksheet Functions 2 January 2nd 07 02:12 PM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM
Close workbook with "Cancel=TRUE" in the BeforeClose()" Wellie[_3_] Excel Programming 1 October 16th 04 09:46 PM


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

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

About Us

"It's about Microsoft Excel"