Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
cancel save lawson Excel Discussion (Misc queries) 1 October 11th 07 11:00 PM
Cancel Save as a Web Page auto republish TJMasters Excel Discussion (Misc queries) 0 March 15th 07 09:24 PM
Save - Yes / No / Cancel Jon Peltier Excel Discussion (Misc queries) 9 May 7th 06 02:03 AM
can I cancel a save juls!1601 Excel Discussion (Misc queries) 2 February 16th 06 01:03 AM
Cancel user's changes but save other changes [email protected] Excel Discussion (Misc queries) 1 December 19th 05 12:09 PM


All times are GMT +1. The time now is 11:48 AM.

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

About Us

"It's about Microsoft Excel"