Save As without VBA project
It works great, Steve. Many thanks. But I'm puzzled as to why there's
no need to specify "Paste" or "Destination"?
Gordon
On Nov 26, 6:13*pm, "Steve Yandl" wrote:
Gordon,
Your idea to copy into a new file is a good option. *The example below
assumes a workbook with three sheets. *It will retain data and formatting
while leaving behind VBA in modules.
'-----------------------------------
Sub SaveWithoutMacro()
Dim intOpens As Integer
intOpens = Application.Workbooks.Count
Worksheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
Set objNewBook = Application.Workbooks(intOpens + 1)
objNewBook.Activate
objNewBook.SaveAs Filename:="MyNewBook.xlsx"
objNewBook.Close
End Sub
'-----------------------------------
Steve Yandl
"Gordon Rainsford" wrote in message
...
After running some VBA code on an Excel file, I'd like to save the
file under a different name, but without saving the code. Is this
possible?
Alternatively I could copy the worksheet into a new file, but I need
to keep all the formatting including column widths & row heights.
Thanks,
Gordon Rainsford- Hide quoted text -
- Show quoted text -
|