Hi,
I have a bit of code I use which opens an existing Excel workbook and saves it as another workbook depending on a variable determined from a form.
When the workbook is saved, it may or may not already exist. If it doesn't exists it works fine, but if it already exists it asks me if I want to overwrite the changes. I can't seem to find a way around this.
Any help would be much appreciated.
Cheers
Paul
I have a bit of code I use which opens an existing Excel workbook and saves it as another workbook depending on a variable determined from a form.
When the workbook is saved, it may or may not already exist. If it doesn't exists it works fine, but if it already exists it asks me if I want to overwrite the changes. I can't seem to find a way around this.
Any help would be much appreciated.
Cheers
Paul
Code:
variablechange = "CR041220081346.xls"
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Set xlApp = New Excel.Application
xlApp.EnableEvents = False
With xlApp
.Visible = True
Set xlWB = .Workbooks.Open("C:\Example\Template.xls", , False)
End With
DoCmd.SetWarnings False
xlWB.SaveAs ("C:\Example\" & variablechange)
xlWB.Close SaveChanges:=True
DoCmd.SetWarnings True