score:0
Accepted answer
if i have to use your code, try something like this:
option explicit
sub save()
dim obj_wb as object
set obj_wb = thisworkbook
application.displayalerts = false
activeworkbook.savecopyas filename:=activeworkbook.path & "audit checklist" & ".xlsm"
msgbox "file saved successfully!", , "save"
debug.print obj_wb.name
application.displayalerts = true
set obj_wb = nothing
end sub
obj_wb is the old file, accessible through this variable. probably it is a good idea to use "thisworkbook" in stead of "activeworkbook". or to refer it always as a variable and not to use any of those at all.
Source: stackoverflow.com
Related Query
- How to retain the original workbook during SaveAs
- How can I SaveAs a new workbook to original workbook directory with Excel VBA?
- How to store the output files in the same folder as the original workbook
- How to get file path, switch to macro file then back to the original active workbook to execute code
- How do I get a range's address including the worksheet name, but not the workbook name, in Excel VBA?
- How to declare Global Variables in Excel VBA to be visible across the Workbook
- How do i determine if an error is in any cell in the entire workbook with Excel VBA
- How to activate a workbook that is open using the name of the workbook in VBA
- Excel VBA - How do I clear the clipboard on another workbook in another application?
- How to get the "Last Saved By" property for workbook file
- How to use Excel .SaveAs but retain original sheet name
- VBA: How to get the local filepath of a workbook that uses the new autosave feature (and thus is technically opened from OneDrive)?
- How do I get back my original file after performing all the Operations on the excel file using VBA?
- How to refer to the workbook where a function is used in Excel VBA?
- How to check if the excel workbook is currently working on a MAC or Windows
- How should I Notify the user during a long process?
- How to update a shared workbook with changes from others before active user data is entered into the sheet?
- VBA: How to address the correct workbook when giving a worksheet as an argument to a function?
- How to obtain the macros defined in an Excel workbook
- How do you reference the workbook that called an Addin from the Addin in Excel?
- How to get Workbook Name after opening the workbook using workbooks.open?
- how to find maximum rows of the sheet of workbook - vba
- How to set the extra workbook location as desktop?
- How to make Worksheet_SelectionChange under the whole workbook range?
- How can I determine the sheet name in a workbook that my function is sitting?
- How to check if CURRENT event is not during the OPEN event of form
- How can I apportion a total by percentages where each cell is an integer and they sum to exactly the original total?
- How can I make my loop move on to the next workbook without repeating itself in the first workbook?
- How to Find the name of the last opened workbook
- How do I hide the formulabar and statusbar in one specific workbook without affecting all other opened workbooks using VBA?
More Query from same tag
- how do I fix subscript out of range error in vba for copying sheets between workbooks
- Excel Data Imported as '15/2, Macro to convert to number?
- Vba copy and paste specifc cells if criteria is met
- Look at the file name before it saves file into a folder
- Swap 2 characters in strings
- VBA Macro seems to freeze when ran with large dataset (NEW TO VBA)
- Figure out the first Calendar Saturday based on the first day of the month
- Worksheet_Calculate event not working
- Weighted average function
- Decrypt mail to Exchange public folder
- how to Create a varios graphs in excel VBA
- Copy formatted data from one sheet to another
- Insert into statement with an apostophe using VBA?
- How to automatically trigger the App Object initialization in Powerpoint?
- VBA Replace colour dependent on drop down value
- Excel vba split function not working
- Loop to save and close each open email leaves one open
- VBA Identify duplicate value in column and select value in row
- Split text in column into words and print them in another column
- Copy zero string Visual Basic Excel
- Alternative to Dir() to check whether network file exist if user doesnt have write access
- Listbox not displaying in UserForm
- Add security to run worksheet_unprotect loop trough sheet even when mutiple sheet are selected
- Receiving an Error " The object you entered is not a valid record set property" access 2013 assigning record set to a form
- VBA copy and paste macro != manual copy paste
- Excel vba-- macro to add a new comment and set focus to that comment
- Remove cell formatting when copying cells from one range to another
- What are the Pros and Cons of VBA Code vs Macros in MS Access?
- What is this VBA primitive data type?
- Excel VBA: If A2="a","b","c",etc... then B2="aa"?