Cancel in Save As and Open
Sub Macro5()
Hi I have written a couple of simple macro's to SaveAs and Open a file. The dialog box's opens fine and saves or open OK. However when I use the cancel button in the dialog box the file is either saved as false.xls or opened as false.xls. Can you please advise what additional code I need to include in the macro and where in the macro. I've included the saveas macro below for reference. I assume the code should include a statement such as Private Sub Work_BeforeClose(Cancel as Boolean). However, as a novice I don't know the full listing to include. Thanks Con ' Macro5 Macro ' Macro recorded 30/12/2003 by Fred ' ' ChDir "C:\Spdsheets\Test" Filt = "Excel Files(*.xls),*.xls" ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename _ (FileFilter:=Filt) End Sub |
Cancel in Save As and Open
Con,
strFilename = Application.GetSaveAsFilename(FileFilter:=Filt) If strFilename < "False" Then ActiveWorkbook.SaveAs strFilename Rob "Con" wrote in message ... Sub Macro5() Hi I have written a couple of simple macro's to SaveAs and Open a file. The dialog box's opens fine and saves or open OK. However when I use the cancel button in the dialog box the file is either saved as false.xls or opened as false.xls. Can you please advise what additional code I need to include in the macro and where in the macro. I've included the saveas macro below for reference. I assume the code should include a statement such as Private Sub Work_BeforeClose(Cancel as Boolean). However, as a novice I don't know the full listing to include. Thanks Con ' Macro5 Macro ' Macro recorded 30/12/2003 by Fred ' ' ChDir "C:\Spdsheets\Test" Filt = "Excel Files(*.xls),*.xls" ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename _ (FileFilter:=Filt) End Sub |
Cancel in Save As and Open
Just an added thought.
While implied by using a name like strFileName, the variable strFileName should be explicitly dim'd as String Dim strFileName as String -- Regards, Tom Ogilvy "Rob van Gelder" wrote in message ... Con, strFilename = Application.GetSaveAsFilename(FileFilter:=Filt) If strFilename < "False" Then ActiveWorkbook.SaveAs strFilename Rob "Con" wrote in message ... Sub Macro5() Hi I have written a couple of simple macro's to SaveAs and Open a file. The dialog box's opens fine and saves or open OK. However when I use the cancel button in the dialog box the file is either saved as false.xls or opened as false.xls. Can you please advise what additional code I need to include in the macro and where in the macro. I've included the saveas macro below for reference. I assume the code should include a statement such as Private Sub Work_BeforeClose(Cancel as Boolean). However, as a novice I don't know the full listing to include. Thanks Con ' Macro5 Macro ' Macro recorded 30/12/2003 by Fred ' ' ChDir "C:\Spdsheets\Test" Filt = "Excel Files(*.xls),*.xls" ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename _ (FileFilter:=Filt) End Sub |
All times are GMT +1. The time now is 05:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com