ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   minimize just opened workbook window (https://www.excelbanter.com/excel-programming/393675-minimize-just-opened-workbook-window.html)

JohnZ[_2_]

minimize just opened workbook window
 
In an Open event subroutine for "workbook1", I open a second workbook
"workbook2" that is defined by label "book2" in a "workbook1" worksheet with
the following statements:

Dim wkbook2 as object
Set wkbook2 = Range("book2")
Workbook.Open (wkbook2)

Question: How do I minimize (xlMinimize) the window for the just opened
"workbook2" using the label "book2" defined in "workbook1"?

Workbooks(wkbook2).ActiveWindow.WindowState = xlMinimized

Above statement does not work.

Jim Thomlinson

minimize just opened workbook window
 
A couple of things... wkbook2 is pointing at a range and not at the workbook
as you might expect it is. Secondly when you open a workbook it is opened in
the active window so to hide it you just need ActiveWindow.WindowState =
xlMinimized. Give this a try...

Dim wkbook2 as Workbook
Workbook.Open (Range("book2").Value)
Set wkbook2 = ActiveWorkbook
ActiveWindow.WindowState = xlMinimized

--
HTH...

Jim Thomlinson


"JohnZ" wrote:

In an Open event subroutine for "workbook1", I open a second workbook
"workbook2" that is defined by label "book2" in a "workbook1" worksheet with
the following statements:

Dim wkbook2 as object
Set wkbook2 = Range("book2")
Workbook.Open (wkbook2)

Question: How do I minimize (xlMinimize) the window for the just opened
"workbook2" using the label "book2" defined in "workbook1"?

Workbooks(wkbook2).ActiveWindow.WindowState = xlMinimized

Above statement does not work.



All times are GMT +1. The time now is 06:49 PM.

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