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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Enable/Disable Macros Pop-Up juamig Excel Discussion (Misc queries) 1 April 9th 10 06:29 PM
Update Cell in WKBook 1 From WkBook 2 pattlee Excel Discussion (Misc queries) 2 May 25th 08 01:27 PM
Using Checkboxes to enable/disable vb [email protected] Excel Programming 6 June 15th 06 05:39 PM
Suppress "Disable/Enable Macros" and Query Refresh dialog on open Sharon Excel Programming 2 January 18th 06 09:20 PM
Enable/Disable Worksheet Change Event code Stuart[_5_] Excel Programming 2 November 3rd 03 07:22 PM


All times are GMT +1. The time now is 07:32 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"