Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Question: File already exists

Hello Everyone,

I have written a macro so that it formats some code, creates another
workbook, and then saves the code to the harddrive. It all works fine, but
I want to save it to the same file name everytime. Is there a command that
I can write that will AUTOMATICALLY save the file and overwrite the file???
After the script runs, then a msgbox pops up and always asks, "calander.csv
already exists, do you want to overwrite??" Can I write some code that will
do that? Here is the code I have now:

ChDir "C:\Program Files\InternetMacros\Downloads"
ActiveWorkbook.SaveAs Filename:= _
"C:\Program Files\InternetMacros\Downloads\calander.csv",
FileFormat:=xlCSV, _
CreateBackup:=False

Any help would be greatly appreciated,

Michael Vaughan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Question: File already exists

application.displayalerts=false
'your code here
application.displayalerts=true


Michael Vaughan wrote:

Hello Everyone,

I have written a macro so that it formats some code, creates another
workbook, and then saves the code to the harddrive. It all works fine, but
I want to save it to the same file name everytime. Is there a command that
I can write that will AUTOMATICALLY save the file and overwrite the file???
After the script runs, then a msgbox pops up and always asks, "calander.csv
already exists, do you want to overwrite??" Can I write some code that will
do that? Here is the code I have now:

ChDir "C:\Program Files\InternetMacros\Downloads"
ActiveWorkbook.SaveAs Filename:= _
"C:\Program Files\InternetMacros\Downloads\calander.csv",
FileFormat:=xlCSV, _
CreateBackup:=False

Any help would be greatly appreciated,

Michael Vaughan


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Question: File already exists

ChDir "C:\Program Files\InternetMacros\Downloads"
Application.displayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Program Files\InternetMacros\Downloads\calander.csv",
FileFormat:=xlCSV, _
CreateBackup:=False
Application.DisplayAlerts = True

or
Dim sStr as String
ChDir "C:\Program Files\InternetMacros\Downloads"
sStr = "C:\Program Files\InternetMacros\Downloads\calander.csv"
On Error Resume Next
Kill sStr
On Error goto 0
ActiveWorkbook.SaveAs Filename:=sStr, _
FileFormat:=xlCSV, _
CreateBackup:=False

--
Regards,
Tom Ogilvy


"Michael Vaughan" wrote in message
. ..
Hello Everyone,

I have written a macro so that it formats some code, creates another
workbook, and then saves the code to the harddrive. It all works fine,

but
I want to save it to the same file name everytime. Is there a command

that
I can write that will AUTOMATICALLY save the file and overwrite the

file???
After the script runs, then a msgbox pops up and always asks,

"calander.csv
already exists, do you want to overwrite??" Can I write some code that

will
do that? Here is the code I have now:

ChDir "C:\Program Files\InternetMacros\Downloads"
ActiveWorkbook.SaveAs Filename:= _
"C:\Program Files\InternetMacros\Downloads\calander.csv",
FileFormat:=xlCSV, _
CreateBackup:=False

Any help would be greatly appreciated,

Michael Vaughan




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

Thanks Dave and Tom!!
:-)


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
File Exists Mike McLellan Excel Discussion (Misc queries) 2 May 4th 06 09:20 AM
File Exists Pflugs Excel Programming 2 September 4th 05 07:05 AM
IF File Exists [email protected] Excel Programming 1 November 22nd 04 07:24 PM
File already exists Michael Malinsky[_3_] Excel Programming 0 June 28th 04 08:02 PM
the file already exists - do you want to replace the existing file? Paul James[_3_] Excel Programming 4 December 12th 03 02:50 AM


All times are GMT +1. The time now is 02:54 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"