Click to See Complete Forum and Search --> : Saving an Excel Sheet


Jim Bassett
December 1st, 1999, 09:28 AM
I am making use of Excel's automation and I use the Excel worksheet method of SaveAs. If the path and name of the file already exists I get the option to either overwrite the existing file, not overwrite, ot cancel. What I need is a way to have the option that if there is an existing file, then be able to input a new name, is there a Excel method that does that?

Lothar Haensler
December 1st, 1999, 09:53 AM
since you use automation (probably from VB), you can use VB to check for the existence of the file as in

Dim strfile as string
strfile = "c:\x.xls"
If Dir(strfile) <> "" then
x.Visible = true
x.WindowState = xlNormal
strfile = x.GetSaveAsFilename(strfile)
End If
x.ActiveWorkbook.SaveAs FileName:=strfile, ConflictResolution:=xlUserResolution