PDA

View Full Version : [SOLVED:] Workbooks object question



sassora
08-02-2014, 12:55 AM
Hi

If I have something like this:

Set wb = app.Workbooks.Add(Template:= "\\Server\...\Template.xlsm")

If I change a cell value and don't save it then are the changes kept if I refer to the wb workbook later in the code? Or will it always refer to the saved version?


Thanks

westconn1
08-02-2014, 02:19 AM
it would depend where wb is defined
if wb is defined within the procedure the changed values would be lost when the procedure ends unless saved, if wb is defined globally then the changes would remain until wb goes out of scope
unless the new workbook is saved all changes will be lost
the template will not be changed unless it is specifically overwritten using save as
if the purpose is to edit the template, then it should be opened, rather than creating a new document based on the template

sassora
08-02-2014, 02:34 AM
Thanks

I am creating many files based on a template, but I am updating some of the template values first.

It sounds like if I used the setup above, the reports I'm making would get updated to with the changes I make but the original template wouldn't. I think I've decided to open and save as instead so I keep the template up to date.

Thanks