Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a piece of code that someone else has written.
There is a line of code that opens another workbook (wkBk2): Workbooks.Open FileName:=(wkBk2) The program does open the new workbook. The next line of code causes a crash (Run-Time error 9): Sheets("April").Activate The problem arises because the "April" worksheet is NOT in the ActiveWorkbook. It is, however, in the newly opened workbook (wkBk2). I would expect the newly opened wkBk2 to be the active workbook (since it was just opened), but it is not. Apparently, this program has been up and running for over a year. Now, however, this piece of code is causing it to crash. I would appreciate some help in understanding why this could all of a sudden stop running. TIA... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Derek, the workbook wkBk2 was saved while it was minimized. This prevents
it from being the active workbook when opened. To make it the activeworkbook, use the following line: Workbooks(wkBk2).Activate Bob Flanagan Macro Systems http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "Derek" wrote in message ... I have a piece of code that someone else has written. There is a line of code that opens another workbook (wkBk2): Workbooks.Open FileName:=(wkBk2) The program does open the new workbook. The next line of code causes a crash (Run-Time error 9): Sheets("April").Activate The problem arises because the "April" worksheet is NOT in the ActiveWorkbook. It is, however, in the newly opened workbook (wkBk2). I would expect the newly opened wkBk2 to be the active workbook (since it was just opened), but it is not. Apparently, this program has been up and running for over a year. Now, however, this piece of code is causing it to crash. I would appreciate some help in understanding why this could all of a sudden stop running. TIA... |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you. You were correct...It was minimized.
-----Original Message----- Derek, the workbook wkBk2 was saved while it was minimized. This prevents it from being the active workbook when opened. To make it the activeworkbook, use the following line: Workbooks(wkBk2).Activate Bob Flanagan Macro Systems http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "Derek" wrote in message ... I have a piece of code that someone else has written. There is a line of code that opens another workbook (wkBk2): Workbooks.Open FileName:=(wkBk2) The program does open the new workbook. The next line of code causes a crash (Run-Time error 9): Sheets("April").Activate The problem arises because the "April" worksheet is NOT in the ActiveWorkbook. It is, however, in the newly opened workbook (wkBk2). I would expect the newly opened wkBk2 to be the active workbook (since it was just opened), but it is not. Apparently, this program has been up and running for over a year. Now, however, this piece of code is causing it to crash. I would appreciate some help in understanding why this could all of a sudden stop running. TIA... . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I stop blank workbook from opening when opening an existing | Excel Discussion (Misc queries) | |||
when opening an Excel Workbook, another blank workbook also opens | Excel Discussion (Misc queries) | |||
when opening an Excel Workbook, another blank workbook also opens | Excel Discussion (Misc queries) | |||
How to make the opening of a workbook conditional upon the opening of another workbook | Excel Programming | |||
How to make opening of workbook conditional of opening of another workbook | Excel Programming |