Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Workbook_open Vick Excel Discussion (Misc queries) 13 February 14th 06 10:40 PM
Workbook_Open () Bill Martin Excel Discussion (Misc queries) 12 December 20th 05 05:37 PM
Workbook_Open not working Sheena N via OfficeKB.com Excel Discussion (Misc queries) 4 May 6th 05 01:31 AM
problem with code in workbook_open event Dominique Schroeder Excel Programming 3 April 7th 04 01:56 AM
Workbook_open Event Bruce Maston Excel Programming 6 April 6th 04 01:19 AM


All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"