ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Personal workbook opens and messes up workbooks(i) (https://www.excelbanter.com/excel-programming/336591-personal-workbook-opens-messes-up-workbooks-i.html)

Mark Stephens[_3_]

Personal workbook opens and messes up workbooks(i)
 
I am referring to workbooks by number (I open a workbook and then refer to
it as workbooks(2). Problem is that when I refer to it, it refers to an
invisible workbook that is opening (personal) without my volition. Can
anyone tell me hwat's going on?

Thanks in advance, kind regards, Mark



Dave Peterson

Personal workbook opens and messes up workbooks(i)
 
I don't think I'd ever trust the index into the workbooks collection.

I'd use a variable (or two):

dim ActWkbk as workbook
dim otherWkbk as workbook

set actwkbk = activeworkbook
set otherwkbk = workbooks.open(filename:=.....)

....

then you can do anything you want by using that variable:

otherwkbk.save
otherwkbk.close savechanges:=false




Mark Stephens wrote:

I am referring to workbooks by number (I open a workbook and then refer to
it as workbooks(2). Problem is that when I refer to it, it refers to an
invisible workbook that is opening (personal) without my volition. Can
anyone tell me hwat's going on?

Thanks in advance, kind regards, Mark


--

Dave Peterson


All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com