Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
cancel save | Excel Discussion (Misc queries) | |||
Cancel Save as a Web Page auto republish | Excel Discussion (Misc queries) | |||
Save - Yes / No / Cancel | Excel Discussion (Misc queries) | |||
can I cancel a save | Excel Discussion (Misc queries) | |||
Cancel user's changes but save other changes | Excel Discussion (Misc queries) |