I'm condensing some of my code here, but I'm getting an error I'm not really sure how to handle, even with the simplicity of what I'm trying to achieve.
Basically when a user selects to name a file that already exists, MS pops up a overwrite file msgbox. but if in that overwrite msgbox the user selects no or cancel, run time error is thrown. I don't really feel like I have control of what is happening as this appears to be contained all within the .saveAs command
sfilename is a string
I tried throwing some checks in before the .saveAs, but as I said, I kind of lose control to MS. Don't know if I'm explaining this well, but any help would be much appreciated! thanks!Code:sfilename = Application.GetSaveAsFilename("nindex_", "Excel files (*.xls), *.xls") If sfilename = "False" Then Exit Sub Application.ScreenUpdating = False Dim oBook As Workbook Set oBook = Application.Workbooks.Add Application.SheetsInNewWorkbook = 1 oBook.SaveAs sfilename 'crashing here if the user selects no/cancel overwrite
go steelers.




Reply With Quote