Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Overwriting a cell with a formula without deleting the formula | Excel Worksheet Functions | |||
Overwriting most of a workbook | Excel Discussion (Misc queries) | |||
Excelfile wants to save before closing | Excel Discussion (Misc queries) | |||
How do i lockup a locked excelfile if i have forgot the password? | Excel Discussion (Misc queries) | |||
Spreadsheets are overwriting each other | Excel Discussion (Misc queries) |