Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default how do you hide a forms command button

I need to be able to hide and display a command button depending on the
occurrence of certain events. What code can I use to hide and display a
command button named "cmdEnterData"?

Thank you in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default how do you hide a forms command button

This is from the Forms toolbar?

Worksheets("Sheet1").Buttons("cmdEnterData").Visib le = True

There's another property that you might like, too: .enabled = True/False

The button will still be there, but won't do anything if you click it.

Paul James wrote:

I need to be able to hide and display a command button depending on the
occurrence of certain events. What code can I use to hide and display a
command button named "cmdEnterData"?

Thank you in advance.


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default how do you hide a forms command button


If ??? True Then
cmdEnterData.Visible = True
Else
cmdEnterData.Visible = False
End If


Hope this helps...

-----Original Message-----
I need to be able to hide and display a command button

depending on the
occurrence of certain events. What code can I use to

hide and display a
command button named "cmdEnterData"?

Thank you in advance.


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default how do you hide a forms command button

sorry, missed the button is on the worksheet and not a
userform...




-----Original Message-----
This is from the Forms toolbar?

Worksheets("Sheet1").Buttons("cmdEnterData").Visi ble =

True

There's another property that you might like,

too: .enabled = True/False

The button will still be there, but won't do anything if

you click it.

Paul James wrote:

I need to be able to hide and display a command button

depending on the
occurrence of certain events. What code can I use to

hide and display a
command button named "cmdEnterData"?

Thank you in advance.


--

Dave Peterson

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default how do you hide a forms command button

I don't think you'll be able to change the color of the button (of the forms
button, you could do it with the controltoolbox toolbar button).

But you could change the fontcolor of the characters on the button (or maybe
strikethrough the characters). Or you could leave the button active and just
assign it to a macro that yells at them.

Maybe you could pick and choose from this snippet.

Option Explicit
Sub testme()

Dim myBtn As Button

Set myBtn = Worksheets("Sheet1").Buttons("cmdEnterData")
With myBtn
.Enabled = True
.Font.ColorIndex = 12
.Font.Strikethrough = True
.OnAction = ThisWorkbook.Name & "!MacroNotAvailable"
End With

End Sub

Sub MacroNotAvailable()
MsgBox "Not available"
End Sub



Paul James wrote:

Thanks to Dave and Jim.

You're right, Dave, I do like the idea of the Enabled property. Question
about that, however. If I used it, I'd like to be able to gray it out,
because if you don't, the user has no visual cue that it's been disabled,
and it might create confusion when he clicks on it. Whereas if it's grayed
out, he's got a visual cue that it's been disabled, presumably for a good
reason.

Is there a property that enables me to gray out the button when the Enabled
property is set to False?

Thanks again.


--

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
Forms Command Button - Removal JMay Excel Discussion (Misc queries) 8 January 4th 07 06:33 PM
Use of Forms Command-button on Worksheet Jim May Excel Discussion (Misc queries) 12 November 13th 06 06:08 PM
Command button on forms Erik (AP Inc.) Excel Discussion (Misc queries) 2 August 28th 06 01:58 PM
Command Button to Hide/Unhide Rows Bea Excel Discussion (Misc queries) 4 March 16th 06 03:21 PM
Hide command button on worksheet Mohair Excel Programming 3 July 14th 03 11:06 PM


All times are GMT +1. The time now is 12:41 AM.

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

About Us

"It's about Microsoft Excel"