Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open problem
Why do I keep getting this error
Run-time error '1004' Unable to set the Width property of the Windows clas In my ThisWorkbook object I have the following code Private Sub Workbook_Open( With ActiveWindo .Width = 27 .Height = 27 End Wit End Su This only errors out when I open Excel with the file. If Excel is already open, no error The worksheet is not protected Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open problem
Try
Private Sub Workbook_Open() With Application.ThisWorkbook.Windows(1) .Width = 275 .Height = 270 End With End Sub -- Regards, Tom Ogilvy "TroyH" wrote in message ... Why do I keep getting this error: Run-time error '1004': Unable to set the Width property of the Windows class In my ThisWorkbook object I have the following code: Private Sub Workbook_Open() With ActiveWindow .Width = 275 .Height = 270 End With End Sub This only errors out when I open Excel with the file. If Excel is already open, no error. The worksheet is not protected. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open problem
Thanks Tom for the reply. It works as well, but I keep getting that error. It will always appear if the last window opened before closing Excel is maximized. If the last window is normal, then there is no problem
Any ideas |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open problem
Well, this is the first time you mentioned anything about maximized windows.
The obvious solution is to check if it is maximized or forget the check and make in normal Private Sub Workbook_Open() With Application.ThisWorkbook.Windows(1) .WindowState = xlNormal .Width = 275 .Height = 270 End With End Sub -- Regards, Tom Ogilvy "TroyH" wrote in message ... Thanks Tom for the reply. It works as well, but I keep getting that error. It will always appear if the last window opened before closing Excel is maximized. If the last window is normal, then there is no problem. Any ideas? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook_Open problem
Thanks Tom. It seems I had the same idea as you. When I checked to see if the windows was normal or maximized and changed accordingly, it worked. D'Oh! I will learn as time goes on
Thanks again. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem with Workbook_open | Excel Discussion (Misc queries) | |||
Workbook_Open () | Excel Discussion (Misc queries) | |||
Workbook_Open not working | Excel Discussion (Misc queries) | |||
problem with code in workbook_open event | Excel Programming | |||
Workbook_open Event | Excel Programming |