I'm working on a Macro and want to know about this to avoid any bugs or crashes.
Scenario: I have a file which does all the processing (Macro File). My code opens a pre-existing excel (Template) file then writes some things into it and then Save As's it at particular location. For Opening pre-existing file, I'm using this:
Set SOWbk = Workbooks.Open(FileName:=SOFileName, ReadOnly:=True)
For Saving As this file, I'm using this:
SOWbk.SaveAs FileName:=ThisWorkbook.Path & "\" & TextBox13.Value & "_SO.xlsm", FileFormat:=52
Questions: 1. After Save As, does the original file (Template) remains open and i have to close it anyhow? 2. Does "SOWbk" Object gets the reference of the newly saved as file automatically?
I tried searching this on Google and on Stack as well. I did not found any help on this. Thank you for your help in advance! Much appreciated.
Answer to Question 1: Does the old workbook stay open after SaveAs
No. You open Workbook A that is stored in Location A. When you use the SaveAs function, you save the "current Version" of the open Workbook (which is not the same as what is stored in Location A) to Location B. The file that is now open is file B so to say.
Answer to Question 2: What happens to the Workbook Object
The Object refers to what i refered to as Workbook B. The explanation is the same as above. The opened workbook is not a representation of what is stored in Location A.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With