Canceling SaveAs dialog box without saving workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please Help!!!!

Problem: I prompt the user it they would like to save the document. If they select Yes then the SaveAs dialog box appears. But if they click the Cancel button on the SaveAs dialog box, it saves the document anyway as "False". How do I return to my code and just resume the next command or event?????


Here's the code that I am using:

saveanswer=msgbox ("Would you like to save?", vbyesno)

If saveanswer=vbyes then
FileSaveName = Application.GetSaveAsFilename(fileFilter:"Microsoft Excel File (*.xls),*.xls")

ActiveWorkbook.SaveAs (FileSaveName)

Elseif saveanswer = vbcancel then
UserForm2.show
End If



Thanks In Advance
— CDotWin
 
You have to test the return from GetSaveAsFileName

saveanswer = MsgBox("Would you like to save?", vbYesNo)

If saveanswer = vbYes Then
filesavename = Application.GetSaveAsFilename(fileFilter:="Microsoft
Excel File (*.xls),*.xls")

If filesavename <> "False" Then
ActiveWorkbook.SaveAs (filesavename)
End If

Else
UserForm2.Show
End If

Also, vbYesNo MsgBox cannot retuirn vbCancel

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

CDotWin said:
Please Help!!!!

Problem: I prompt the user it they would like to save the document. If
they select Yes then the SaveAs dialog box appears. But if they click the
Cancel button on the SaveAs dialog box, it saves the document anyway as
"False". How do I return to my code and just resume the next command or
event?????
 
Even when I put in the code to test the filesavename, it continues to save . as "FALSE.xls". I dont know why its still doing that and how to fix it. Please help.
 
I have just tried it again, and I don't get that result.

have you stepped through the code?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

CDotWin said:
Even when I put in the code to test the filesavename, it continues to save
.. as "FALSE.xls". I dont know why its still doing that and how to fix it.
Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top