![]() |
How can i Enable/Disable CommandButtons from Wkbook Open event ???
Private Sub Workbook_Open()
Sheets("Intro").Activate With Application MsgBox "Welcome " & "*** " & .UserName & " ***" & " to the Tracker File.", vbInformation End With If Sheets("Data").Range("A1").Value = "" Then CommandButton1.Enabled = False Else CommandButton1.Enabled = True End If End Sub The above code returns a Compile error. How can i get it to work? Corey.... |
How can i Enable/Disable CommandButtons from Wkbook Open event ???
Is that commandbutton on the Intro sheet or the Data sheet?
I'm guessing Intro: Option Explicit Private Sub Workbook_Open() With Sheets("Intro") .Select MsgBox "Welcome " & "*** " & Application.UserName _ & " ***" & " to the Tracker File.", vbInformation If Sheets("Data").Range("A1").Value = "" Then .CommandButton1.Enabled = False Else .CommandButton1.Enabled = True End If End With End Sub Notice the dots in front of .commandbutton1. This means that it belongs to the object in the previous With statement--in this case the Intro sheet. Coza wrote: Private Sub Workbook_Open() Sheets("Intro").Activate With Application MsgBox "Welcome " & "*** " & .UserName & " ***" & " to the Tracker File.", vbInformation End With If Sheets("Data").Range("A1").Value = "" Then CommandButton1.Enabled = False Else CommandButton1.Enabled = True End If End Sub The above code returns a Compile error. How can i get it to work? Corey.... -- Dave Peterson |
All times are GMT +1. The time now is 12:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com