EagleEyeVB
New member
- Joined
- Aug 28, 2005
- Messages
- 4
- Programming Experience
- Beginner
Hi, I need to overwrite an Excel spreadsheet file, but can't seem to figure it out. I'm not using a file dialog window, just saving directly to the same location. Here's my code:
'Create a new workbook in Excel.
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "Test"
'Save the workbook and quit Excel.
oBook.SaveAs("Test.xls")
oSheet = Nothing
oBook = Nothing
oExcel.Quit()
It prompts me,
A file named "Test.xls" already exits in this location. Do you want to replace it?
at the oBook.SaveAs("Test.xls"). How do I turn that off, so it doesn't prompt the message?
Thanks for your help.
'Create a new workbook in Excel.
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "Test"
'Save the workbook and quit Excel.
oBook.SaveAs("Test.xls")
oSheet = Nothing
oBook = Nothing
oExcel.Quit()
It prompts me,
A file named "Test.xls" already exits in this location. Do you want to replace it?
at the oBook.SaveAs("Test.xls"). How do I turn that off, so it doesn't prompt the message?
Thanks for your help.