Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
From another thread I worked how to disable and "grey out" a "commandbutton",
but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Exactly the same
Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Bob,
Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
The keyword 'Me' refers to the object that contains it. So for a
class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Chip,
Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Is that button on a userform?
If yes, is the code to disable the button behind that userform? If yes, then Me refers to that userform. If the button is on a worksheet and is a commandbutton from the control toolbox toolbar and the code is behind that worksheet, then Me refers to that worksheet. Trefor wrote: Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Trefor,
You may not know it, but userform code modules are a specific type of class module. If you want to disable a button on a userform, there must be something, some situation, that will determine when that button is to be disabled. What is that? Also, as you call it Button 30, it makes me think that you are referring to worksheets not a userform at all. Can you clarify? -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Trefor,
Following Bob's observation about your button named "Button 30", I guess it is neither a userform button nor a Commanbutton but a button on a sheet applied with the Forms toolbar. If so try this in a Normal module Sub TestEnable() EnableButton "Button 30", True End Sub Sub TestDisable() EnableButton "Button 30", False End Sub Function EnableButton(sBtnName As String, bEnable As Boolean) Dim btn As Button On Error Resume Next Set btn = ActiveSheet.Buttons(sBtnName) If btn Is Nothing Then MsgBox sBtnName & " does not exist on this sheet" Else btn.Enabled = bEnable 'simulate greyed out text if disabled btn.Font.Color = IIf(bEnable, 0, RGB(150, 150, 150)) End If End Function Regards, Peter T "Bob Phillips" wrote in message ... Trefor, You may not know it, but userform code modules are a specific type of class module. If you want to disable a button on a userform, there must be something, some situation, that will determine when that button is to be disabled. What is that? Also, as you call it Button 30, it makes me think that you are referring to worksheets not a userform at all. Can you clarify? -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Peter/Bob/Dave,
Thankyou all for your replies and yes my "new guy" terminology finally got deciphered by Peter, yes indeed a €śsheet with a button from the forms toolbar€ť. Dave, Currently I set a variable to €śdisabled€ť on a certain event, each macro that runs from the button checks this variable and if set to €śdisabled€ť simply does an Exit Sub and the macro obviously does not run. Peter your code does indeed disable the button and forces the colour of the text to grey and then back to black afterwards, thankyou for this. Unfortunately the button colour is not black (its blue) and in some cases has two different colours (Red and Blue). The disable on the CommandButton on a sheet from the Control Toolbox seemed to be neat and easy, but clearly not so neat on a button from the forms toolbar? I presume there is a way to check the colour on the button, save it to a variable and return it when finished, but I presume this would be all too hard with multiple colours? -- Trefor "Peter T" wrote: Trefor, Following Bob's observation about your button named "Button 30", I guess it is neither a userform button nor a Commanbutton but a button on a sheet applied with the Forms toolbar. If so try this in a Normal module Sub TestEnable() EnableButton "Button 30", True End Sub Sub TestDisable() EnableButton "Button 30", False End Sub Function EnableButton(sBtnName As String, bEnable As Boolean) Dim btn As Button On Error Resume Next Set btn = ActiveSheet.Buttons(sBtnName) If btn Is Nothing Then MsgBox sBtnName & " does not exist on this sheet" Else btn.Enabled = bEnable 'simulate greyed out text if disabled btn.Font.Color = IIf(bEnable, 0, RGB(150, 150, 150)) End If End Function Regards, Peter T "Bob Phillips" wrote in message ... Trefor, You may not know it, but userform code modules are a specific type of class module. If you want to disable a button on a userform, there must be something, some situation, that will determine when that button is to be disabled. What is that? Also, as you call it Button 30, it makes me think that you are referring to worksheets not a userform at all. Can you clarify? -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
worksheets("sheet1").buttons("button 1").enabled = false
For the easy response. Trefor wrote: Peter/Bob/Dave, Thankyou all for your replies and yes my "new guy" terminology finally got deciphered by Peter, yes indeed a €śsheet with a button from the forms toolbar€ť. Dave, Currently I set a variable to €śdisabled€ť on a certain event, each macro that runs from the button checks this variable and if set to €śdisabled€ť simply does an Exit Sub and the macro obviously does not run. Peter your code does indeed disable the button and forces the colour of the text to grey and then back to black afterwards, thankyou for this. Unfortunately the button colour is not black (its blue) and in some cases has two different colours (Red and Blue). The disable on the CommandButton on a sheet from the Control Toolbox seemed to be neat and easy, but clearly not so neat on a button from the forms toolbar? I presume there is a way to check the colour on the button, save it to a variable and return it when finished, but I presume this would be all too hard with multiple colours? -- Trefor "Peter T" wrote: Trefor, Following Bob's observation about your button named "Button 30", I guess it is neither a userform button nor a Commanbutton but a button on a sheet applied with the Forms toolbar. If so try this in a Normal module Sub TestEnable() EnableButton "Button 30", True End Sub Sub TestDisable() EnableButton "Button 30", False End Sub Function EnableButton(sBtnName As String, bEnable As Boolean) Dim btn As Button On Error Resume Next Set btn = ActiveSheet.Buttons(sBtnName) If btn Is Nothing Then MsgBox sBtnName & " does not exist on this sheet" Else btn.Enabled = bEnable 'simulate greyed out text if disabled btn.Font.Color = IIf(bEnable, 0, RGB(150, 150, 150)) End If End Function Regards, Peter T "Bob Phillips" wrote in message ... Trefor, You may not know it, but userform code modules are a specific type of class module. If you want to disable a button on a userform, there must be something, some situation, that will determine when that button is to be disabled. What is that? Also, as you call it Button 30, it makes me think that you are referring to worksheets not a userform at all. Can you clarify? -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor -- Dave Peterson |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Dave,
Indeed a simple one line version of Peter's code, but this does not "grey out" the button. To me this leave the user wondering why the button is not working, "grey'd out" makes it clear that it has been disabled for some reason. Apart from the early Exit Sub, I have a Msgbox, stating that the button had been disabled, I just thought there may be a more elegant way of doing this -- Trefor "Dave Peterson" wrote: worksheets("sheet1").buttons("button 1").enabled = false For the easy response. Trefor wrote: Peter/Bob/Dave, Thankyou all for your replies and yes my "new guy" terminology finally got deciphered by Peter, yes indeed a €œsheet with a button from the forms toolbar€. Dave, Currently I set a variable to €œdisabled€ on a certain event, each macro that runs from the button checks this variable and if set to €œdisabled€ simply does an Exit Sub and the macro obviously does not run. Peter your code does indeed disable the button and forces the colour of the text to grey and then back to black afterwards, thankyou for this. Unfortunately the button colour is not black (its blue) and in some cases has two different colours (Red and Blue). The disable on the CommandButton on a sheet from the Control Toolbox seemed to be neat and easy, but clearly not so neat on a button from the forms toolbar? I presume there is a way to check the colour on the button, save it to a variable and return it when finished, but I presume this would be all too hard with multiple colours? -- Trefor "Peter T" wrote: Trefor, Following Bob's observation about your button named "Button 30", I guess it is neither a userform button nor a Commanbutton but a button on a sheet applied with the Forms toolbar. If so try this in a Normal module Sub TestEnable() EnableButton "Button 30", True End Sub Sub TestDisable() EnableButton "Button 30", False End Sub Function EnableButton(sBtnName As String, bEnable As Boolean) Dim btn As Button On Error Resume Next Set btn = ActiveSheet.Buttons(sBtnName) If btn Is Nothing Then MsgBox sBtnName & " does not exist on this sheet" Else btn.Enabled = bEnable 'simulate greyed out text if disabled btn.Font.Color = IIf(bEnable, 0, RGB(150, 150, 150)) End If End Function Regards, Peter T "Bob Phillips" wrote in message ... Trefor, You may not know it, but userform code modules are a specific type of class module. If you want to disable a button on a userform, there must be something, some situation, that will determine when that button is to be disabled. What is that? Also, as you call it Button 30, it makes me think that you are referring to worksheets not a userform at all. Can you clarify? -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor -- Dave Peterson |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Userform button
Try to stay with the discussion Dave. <g Disabling a forms button does not change the appearance. to the OP, You can certainly store the information on the color of the Font of the button before you change it and then use that information later to change it back. Where you should store it would depend on what your code is doing and how long it will have to be stored. (will the workbook be closed in the meantime for example). Also, the information on Forms buttons was provided earlier in response to your hide a button thread. If your going to start threads, please have the courtesy to check for answers. -- Regards, Tom Ogilvy "Dave Peterson" wrote in message ... worksheets("sheet1").buttons("button 1").enabled = false For the easy response. Trefor wrote: Peter/Bob/Dave, Thankyou all for your replies and yes my "new guy" terminology finally got deciphered by Peter, yes indeed a ?osheet with a button from the forms toolbar?ť. Dave, Currently I set a variable to ?odisabled?ť on a certain event, each macro that runs from the button checks this variable and if set to ?odisabled?ť simply does an Exit Sub and the macro obviously does not run. Peter your code does indeed disable the button and forces the colour of the text to grey and then back to black afterwards, thankyou for this. Unfortunately the button colour is not black (its blue) and in some cases has two different colours (Red and Blue). The disable on the CommandButton on a sheet from the Control Toolbox seemed to be neat and easy, but clearly not so neat on a button from the forms toolbar? I presume there is a way to check the colour on the button, save it to a variable and return it when finished, but I presume this would be all too hard with multiple colours? -- Trefor "Peter T" wrote: Trefor, Following Bob's observation about your button named "Button 30", I guess it is neither a userform button nor a Commanbutton but a button on a sheet applied with the Forms toolbar. If so try this in a Normal module Sub TestEnable() EnableButton "Button 30", True End Sub Sub TestDisable() EnableButton "Button 30", False End Sub Function EnableButton(sBtnName As String, bEnable As Boolean) Dim btn As Button On Error Resume Next Set btn = ActiveSheet.Buttons(sBtnName) If btn Is Nothing Then MsgBox sBtnName & " does not exist on this sheet" Else btn.Enabled = bEnable 'simulate greyed out text if disabled btn.Font.Color = IIf(bEnable, 0, RGB(150, 150, 150)) End If End Function Regards, Peter T "Bob Phillips" wrote in message ... Trefor, You may not know it, but userform code modules are a specific type of class module. If you want to disable a button on a userform, there must be something, some situation, that will determine when that button is to be disabled. What is that? Also, as you call it Button 30, it makes me think that you are referring to worksheets not a userform at all. Can you clarify? -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... Chip, Sorry I am new to VBA and whatever you just said went way over the top of my head! ;) As for Class modules, I have not got passed Modules yet. Can you help me out this some code for a Module please? -- Trefor "Chip Pearson" wrote: The keyword 'Me' refers to the object that contains it. So for a class module, it refers to that instance of the class, for a userform, it refers to the form, etc. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Trefor" wrote in message ... Bob, Sorry what is "Me"? And for "Button 30" is it CommandButton30? Can you use CommandButton(1)? -- Trefor "Bob Phillips" wrote: Exactly the same Me.CommandButton1.Enabled = False -- HTH RP (remove nothere from the email address if mailing direct) "Trefor" wrote in message ... From another thread I worked how to disable and "grey out" a "commandbutton", but I am using a Userforms "Button" is it possible to grey out this type of button? -- Trefor -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Disable Exit button on a UserForm | Excel Discussion (Misc queries) | |||
Looping procedure calls userform; how to exit loop (via userform button)? | Excel Programming | |||
disable the x button on a userform | Excel Programming | |||
How to disable the Exit Button of UserForm in Excel? | Excel Programming | |||
Disable close button of Modeless Userform | Excel Programming |