LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Range.Select error and screen maximizing error in Workbook_Open()

Hi,

I have a routine in ThisWorkbook so that when the workbook is opened,
it first protects the worksheets and workbook so that the user cannot
make changes except where allowed. I also want the workbook to open to
a certain worksheet and cell each time the file is opened. I'm running
into two problems:

First, I've had problems with this workbook such that it opens
minimized and does not allow the option to maximize the screen.
Running this macro while having other Excel workbooks open also tends
to cause the other workbook to have the same problem after that other
file is saved and re-opened separately. Perhaps my macro isn't being
limited to the proper workbook?

Second, when the workbook opens, I get a runtime error 91 object
variable or with block variable not set. This occurs after the
range.select and before the splash.

Any suggestions would be appreciated!


Sub Workbook_Open()

' Maximize all windows

ActiveWorkbook.Unprotect Password:="Password"
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
ActiveWorkbook.Protect Password:="Password", Structu=True,
Windows:=True

' Opens workbook to Table of Contents cell A1 upon opening the
workbook.

ThisWorkbook.Sheets("Contents").Range("a1").Select


' Show splash screen upon opening the workbook

MySplashForm.Show

' Password-protect all worksheets but lets macros hide/delete

Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="Password",
userinterfaceonly:=True, AllowFormattingCells:=True,
AllowFormattingColumns:=True, AllowFormattingRows:=True
ws.EnableSelection = xlNoRestrictions
Next ws
Application.ScreenUpdating = True

End Sub

 
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
Can't select range. Why the error? agentsmith83 Excel Programming 1 April 18th 06 04:38 PM
Help with this error Unknown reason for error with Range().Select Brad Sumner Excel Programming 1 September 13th 05 04:24 PM
Range Select Error sailingdan Excel Programming 1 June 14th 04 04:24 PM
Workbook_Open() Error Minitman[_4_] Excel Programming 5 April 2nd 04 07:59 PM
Run-time 1004 error on range select Morgan[_3_] Excel Programming 3 November 11th 03 11:44 PM


All times are GMT +1. The time now is 09:47 PM.

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

About Us

"It's about Microsoft Excel"