0

How do I make it so that if a file with the same name already exists, it will be quietly overwritten?

Dim oExcel
Dim oBook
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))

'What options to add?
oBook.SaveAs "out.csv", 6

oBook.Close False
oExcel.Quit
MxLDevs
  • 19,048
  • 36
  • 123
  • 194

1 Answers1

0

Use .DisplayAlerts = False to turn such questions off.

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • Where do I put this? When I write it on its own line, I get a "Invalid or unqualified reference". Note that I save the script as `.vbs` and just let windows figure out what to use. Not sure if I should run it differently. – MxLDevs Dec 04 '13 at 18:40
  • @Keikoku - didn't you see it used in the code of http://stackoverflow.com/a/20382898/603855 – Ekkehard.Horner Dec 04 '13 at 18:43
  • ah, that's what you meant by the leading `.` – MxLDevs Dec 04 '13 at 19:06