View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Workbook_Open Problem ... Worksheets not loaded yet!?

Joe,

I haven't tried this myself, but you could use OnTime in the Workbook_Open.
Something like

Private Sub Workbook_Open()

If ThisWorkbook.ReadOnly Then
Application.Ontime Now + timeserial(0,0,1), "DisableButton"
End If

and then in a general module

Sub DisableButton()
ThisWorkbook.Sheets("Sheet2").Shapes("xButton").Co ntrolFormat.Enabled =
False
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Joe HM" wrote in message
oups.com...
Hello -

I want to make sure that some buttons on one of the sheets of a
workbook are disabled if the file was opened in read-only. I put the
following in the Activate() handler of that workbook:

Private Sub Worksheet_Activate()
If ThisWorkbook.ReadOnly Then

ThisWorkbook.Sheets("Sheet2").Shapes("xButton").Co ntrolFormat.Enabled =
False

...

The only problem with that is that if the workbook is opened with that
sheet being visible (active) already, it won't work until I switched
sheets and come back to this one.

I tried to put something similiar into the Workbook_Open() handler but
there seems to be a problem since that is called without all the sheets
being loaded. Is there a way I can wait until all the sheets are
loaded in there and then disable my buttons?

Thanks so much!
Joe