Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

vba Cancel Save As

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JAO - 25 Jan 2008 17:36 GMT
I have written a macro that shows the Save As dialogue box, but I'd like to
add code that closes a workbook if the user selects "cancel".

Can anyone help?
Matthew Pfluger - 25 Jan 2008 18:32 GMT
When using the GetSaveAsFilename method, the method returns FALSE if the user
clicks Cancel.  Thus, you only need to check the result of the method.

Dim response
response = Application.GetSaveAsFilename

if not response then
  ' User clicked false
  Workbooks(NumberOrNameHere).close
else
  ' Do stuff
End if

HTH,
Matthew Pfluger

> I have written a macro that shows the Save As dialogue box, but I'd like to
> add code that closes a workbook if the user selects "cancel".
>
> Can anyone help?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.