#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Saveas

I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" & ls_SmallSaveName &
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to replace
it.

How can I handle it if the user says 'No'?

Thanks,

Dale


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Saveas

Hi
to save in all cases try
application.displayalerts=false
ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" &
ls_SmallSaveName &
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
application.displayalerts=True



--
Regards
Frank Kabel
Frankfurt, Germany


Dale Levesque wrote:
I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" &
ls_SmallSaveName & ".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to
replace it.

How can I handle it if the user says 'No'?

Thanks,

Dale


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Saveas

Dale,

What do you mean by handle it? If you are happy that the user can say no,
then there is nothing more to do.If you are not happy with this and insist
that it is saved, you could precede the SaveAs with

Application.DisplayAlerts = False

and then the question doesn't get asked. Reset to True afterwards.

--
HTH

-------

Bob Phillips
"Dale Levesque" <dale at dynamicwindows.com wrote in message
...
I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" & ls_SmallSaveName &
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to replace
it.

How can I handle it if the user says 'No'?

Thanks,

Dale




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Saveas

No Frank, I'd like to close the current workbook without saving as the
specified name when the user selects 'No'.

Dale

"Frank Kabel" wrote in message
...
Hi
to save in all cases try
application.displayalerts=false
ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" &
ls_SmallSaveName &
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
application.displayalerts=True



--
Regards
Frank Kabel
Frankfurt, Germany


Dale Levesque wrote:
I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" &
ls_SmallSaveName & ".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to
replace it.

How can I handle it if the user says 'No'?

Thanks,

Dale




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Saveas

By handle it I mean that if the user selects 'No'. The sub exits gracefully
without an error message.

Dale

"Bob Phillips" wrote in message
...
Dale,

What do you mean by handle it? If you are happy that the user can say no,
then there is nothing more to do.If you are not happy with this and insist
that it is saved, you could precede the SaveAs with

Application.DisplayAlerts = False

and then the question doesn't get asked. Reset to True afterwards.

--
HTH

-------

Bob Phillips
"Dale Levesque" <dale at dynamicwindows.com wrote in message
...
I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" & ls_SmallSaveName

&
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to

replace
it.

How can I handle it if the user says 'No'?

Thanks,

Dale








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Saveas

Test for the existence of a file before you attempt to save it.
Put up a msgbox to query the user and react to the result.


If dir("c:\mypath\myfile.xls") < "" then
ans = Msgbox( "Overwrite", vbYesNo)
if ans = vbNo then
exit sub
else
kill "c:\mypath\myfile.xls"
End if
End if

' do the save



--
Regards,
Tom Ogilvy

"Dale Levesque" <dale at dynamicwindows.com wrote in message
...
By handle it I mean that if the user selects 'No'. The sub exits

gracefully
without an error message.

Dale

"Bob Phillips" wrote in message
...
Dale,

What do you mean by handle it? If you are happy that the user can say

no,
then there is nothing more to do.If you are not happy with this and

insist
that it is saved, you could precede the SaveAs with

Application.DisplayAlerts = False

and then the question doesn't get asked. Reset to True afterwards.

--
HTH

-------

Bob Phillips
"Dale Levesque" <dale at dynamicwindows.com wrote in message
...
I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" &

ls_SmallSaveName
&
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to

replace
it.

How can I handle it if the user says 'No'?

Thanks,

Dale








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Saveas

Thanks very much. I was hoping that there would be some kind of return value
or way to trap the saveas method error but your suggestion will work nicely.

Dale

"Tom Ogilvy" wrote in message
...
Test for the existence of a file before you attempt to save it.
Put up a msgbox to query the user and react to the result.


If dir("c:\mypath\myfile.xls") < "" then
ans = Msgbox( "Overwrite", vbYesNo)
if ans = vbNo then
exit sub
else
kill "c:\mypath\myfile.xls"
End if
End if

' do the save



--
Regards,
Tom Ogilvy

"Dale Levesque" <dale at dynamicwindows.com wrote in message
...
By handle it I mean that if the user selects 'No'. The sub exits

gracefully
without an error message.

Dale

"Bob Phillips" wrote in message
...
Dale,

What do you mean by handle it? If you are happy that the user can say

no,
then there is nothing more to do.If you are not happy with this and

insist
that it is saved, you could precede the SaveAs with

Application.DisplayAlerts = False

and then the question doesn't get asked. Reset to True afterwards.

--
HTH

-------

Bob Phillips
"Dale Levesque" <dale at dynamicwindows.com wrote in message
...
I'm using the following code to save a file.

ActiveWorkbook.SaveAs FileName:=fs_Path & "Data\" &

ls_SmallSaveName
&
".xls", FileFormat:= _
xlNormal, Password:="", writerespassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

A dialog box comes up if the file already exists asking whether to

replace
it.

How can I handle it if the user says 'No'?

Thanks,

Dale










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
VBA SaveAs Value charlie Excel Discussion (Misc queries) 4 August 27th 07 11:33 PM
SaveAs Stan Halls Excel Worksheet Functions 5 November 28th 06 07:51 PM
Help with saveas Glen Mettler[_2_] Excel Programming 2 February 12th 04 11:00 PM
SaveAs Darrin Henry Excel Programming 0 September 12th 03 10:09 PM
SaveAs Dave Peterson[_3_] Excel Programming 1 September 12th 03 12:44 AM


All times are GMT +1. The time now is 07:37 AM.

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

About Us

"It's about Microsoft Excel"