PC Review


Reply
Thread Tools Rate Thread

How can i Enable/Disable CommandButtons from Wkbook Open event ???

 
 
Coza
Guest
Posts: n/a
 
      22nd Mar 2007
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....


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      22nd Mar 2007
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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Cell in WKBook 1 From WkBook 2 pattlee Microsoft Excel Misc 2 25th May 2008 01:27 PM
VBA Open Wkbook Disabling Macros Karen53 Microsoft Excel Programming 9 21st Mar 2008 08:54 PM
How to disable/enable: File->Open (Open as Web Browser) checkbox in IE6? dewo Windows XP Internet Explorer 0 10th Feb 2006 01:03 AM
WMI Network Adapter enable/disable event notification Andreas F. Wehowsky Windows XP WMI 0 13th Aug 2004 03:26 PM
Enable/Disable Worksheet Change Event code Stuart Microsoft Excel Programming 2 3rd Nov 2003 07:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:08 PM.