Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default deleting/overwriting an excelfile

Hi, I am using the following command to create a new excel file named
"Log.xls" (RetStr is defined above in the macro...)

Dim dummy As String
dummy = RetStr + "\Log.xls"

Set newBook = Workbooks.Add
With newBook
.Title = "ErrorLogs"
.SaveAs Filename:=dummy
End With

That works very good. But i need a routine that checks if the file already
exists. And if so, delete/overwrite that file before creating it (again).

Any hints?

TIA Walt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default deleting/overwriting an excelfile

Set newBook = Workbooks.Add
With newBook
.Title = "ErrorLogs"
Application.DisplayAlerts = False
.SaveAs Filename:=dummy
Application.DisplayAlerts = True
End With



Regards,
Tom Ogilvy

"walt" wrote in message
...
Hi, I am using the following command to create a new excel file named
"Log.xls" (RetStr is defined above in the macro...)

Dim dummy As String
dummy = RetStr + "\Log.xls"

Set newBook = Workbooks.Add
With newBook
.Title = "ErrorLogs"
.SaveAs Filename:=dummy
End With

That works very good. But i need a routine that checks if the file already
exists. And if so, delete/overwrite that file before creating it (again).

Any hints?

TIA Walt




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default deleting/overwriting an excelfile

I prefer to use something that check if it is already open
and then close it,
On Error Resume Next
Dim dummy As String
dummy = RetStr + "\Log.xls"
Workbooks("Log.xls").Close False
Set newBook = Workbooks.Add
With newBook
.Title = "ErrorLogs"
Application.DisplayAlerts = False
.SaveAs Filename:=dummy
Application.DisplayAlerts = True
End With


Francisco Mariscal
fcomariscal at hotmail dot com


-----Original Message-----
Set newBook = Workbooks.Add
With newBook
.Title = "ErrorLogs"
Application.DisplayAlerts = False
.SaveAs Filename:=dummy
Application.DisplayAlerts = True
End With



Regards,
Tom Ogilvy

"walt" wrote in message
...
Hi, I am using the following command to create a new

excel file named
"Log.xls" (RetStr is defined above in the macro...)

Dim dummy As String
dummy = RetStr + "\Log.xls"

Set newBook = Workbooks.Add
With newBook
.Title = "ErrorLogs"
.SaveAs Filename:=dummy
End With

That works very good. But i need a routine that checks

if the file already
exists. And if so, delete/overwrite that file before

creating it (again).

Any hints?

TIA Walt




.

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
Overwriting a cell with a formula without deleting the formula MsBeverlee Excel Worksheet Functions 1 January 16th 10 02:09 PM
Overwriting most of a workbook Brad Excel Discussion (Misc queries) 3 July 2nd 07 02:42 PM
Excelfile wants to save before closing Carlo Excel Discussion (Misc queries) 5 February 2nd 07 11:01 AM
How do i lockup a locked excelfile if i have forgot the password? Halil Excel Discussion (Misc queries) 3 September 14th 05 03:43 PM
Spreadsheets are overwriting each other Bryan Excel Discussion (Misc queries) 5 August 12th 05 01:51 PM


All times are GMT +1. The time now is 11:50 PM.

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"