Reputation: 565
I have a Excel sheet, and if I save the file using the Save as...
option in Excel VBA the currently open document would close, and switch over to the newly created document.
How can I save a copy of the document without switching over the control?
Upvotes: 0
Views: 2466
Reputation: 565
file_name = Application.GetSaveAsFilename(InitialFileName:="File Name", _
filefilter:="Excel Files,*.xls,All Files,*.*", _
Title:="Save As File Name")
Worksheets("Sheet1").Copy
Set wb = ActiveWorkbook
wb.SaveAs Filename:=file_name
wb.Close
Upvotes: 0
Reputation: 23550
You can use SaveCopyAs to do what you want
ActiveWorkbook.SaveCopyAs "C:\XXXX.XLS"
Upvotes: 3
Reputation: 6021
CurrentFile = ThisWorkbook.FullName
ActiveWorkbook.SaveAs "C:\myfile.xls", FileFormat:=52
Workbooks.Open CurrentFile
Upvotes: 4