Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have tried to create a macro using recorder to disable/enable command
button (ActiveX) with the following code being created ActiveSheet.Shapes("CommandButton1").Select This only results in the command button being selected - with the procedure of enabling/disabling being "lost". So i tried the following code ActiveSheet.CommandButton1.Select CommandButton1.Enabled = False This presents runtime error message "object required" What is the "simplest" way to create this macro? (first time user) Any help much appreciated |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you can try this to hide/unhide specific button like"button1"
Sub hide_specific_button() ActiveSheet.Shapes("Button 1").Visible = False End Sub Sub unhide_specific_button() ActiveSheet.Shapes("Button 1").Visible = True End Sub i hop this helpful |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
You don't have to select the button to enable/disable it, just use the object reference as recorded: If Activesheet.Shapes("CommandButton1").Enabled=true then Activesheet.Shapes("CommandButton1").Enabled=False Else Activesheet.Shapes("CommandButton1").Enabled=True End If Hopes this helps. .... Per "enahs_naneek" <u58016@uwe skrev i meddelelsen news:a32c6d168a34a@uwe... I have tried to create a macro using recorder to disable/enable command button (ActiveX) with the following code being created ActiveSheet.Shapes("CommandButton1").Select This only results in the command button being selected - with the procedure of enabling/disabling being "lost". So i tried the following code ActiveSheet.CommandButton1.Select CommandButton1.Enabled = False This presents runtime error message "object required" What is the "simplest" way to create this macro? (first time user) Any help much appreciated |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you for your reply
I have entered the code you provided within my "Disable" macro (shown below) Sub Disable() ' ' Disable Macro ' Macro recorded 05/02/2010 by enahs naneek ' ' If ActiveSheet.Shapes("CommandButton1").Enabled = True Then ActiveSheet.Shapes("CommandButton1").Enabled = False Else ActiveSheet.Shapes("CommandButton1").Enabled = True End If End Sub Results in error message "object doesnt support this property or method" This macro (forming part of a larger macro) will be assigned to a second command button so that when the full macro process is complete i can either disable or enable the first command button by editing the code to what is required (true or false) e.g. "Add" command button enables or disables "Edit" command button. Will the code you provided work this way Much appreciated __________________________________________________ ____ Per Jessen wrote: Hi You don't have to select the button to enable/disable it, just use the object reference as recorded: If Activesheet.Shapes("CommandButton1").Enabled=true then Activesheet.Shapes("CommandButton1").Enabled=False Else Activesheet.Shapes("CommandButton1").Enabled=True End If Hopes this helps. ... Per I have tried to create a macro using recorder to disable/enable command button (ActiveX) with the following code being created [quoted text clipped - 13 lines] Any help much appreciated |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There are some ways to disable commandbutton.
One way is Sub Disable() ActiveSheet.OLEObjects("CommandButton1").Enabled = False End Sub Keiji enahs_naneek wrote: Thank you for your reply I have entered the code you provided within my "Disable" macro (shown below) Sub Disable() ' ' Disable Macro ' Macro recorded 05/02/2010 by enahs naneek ' ' If ActiveSheet.Shapes("CommandButton1").Enabled = True Then ActiveSheet.Shapes("CommandButton1").Enabled = False Else ActiveSheet.Shapes("CommandButton1").Enabled = True End If End Sub Results in error message "object doesnt support this property or method" This macro (forming part of a larger macro) will be assigned to a second command button so that when the full macro process is complete i can either disable or enable the first command button by editing the code to what is required (true or false) e.g. "Add" command button enables or disables "Edit" command button. Will the code you provided work this way Much appreciated __________________________________________________ ____ Per Jessen wrote: Hi You don't have to select the button to enable/disable it, just use the object reference as recorded: If Activesheet.Shapes("CommandButton1").Enabled=true then Activesheet.Shapes("CommandButton1").Enabled=False Else Activesheet.Shapes("CommandButton1").Enabled=True End If Hopes this helps. ... Per I have tried to create a macro using recorder to disable/enable command button (ActiveX) with the following code being created [quoted text clipped - 13 lines] Any help much appreciated |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you keiji - it worked perfectly
_______________________________ keiji kounoike wrote: There are some ways to disable commandbutton. One way is Sub Disable() ActiveSheet.OLEObjects("CommandButton1").Enabled = False End Sub Keiji Thank you for your reply I have entered the code you provided within my "Disable" macro (shown below) [quoted text clipped - 46 lines] [quoted text clipped - 13 lines] Any help much appreciated |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're welcome.
Keiji enahs_naneek wrote: Thank you keiji - it worked perfectly _______________________________ keiji kounoike wrote: There are some ways to disable commandbutton. One way is Sub Disable() ActiveSheet.OLEObjects("CommandButton1").Enabled = False End Sub Keiji Thank you for your reply I have entered the code you provided within my "Disable" macro (shown below) [quoted text clipped - 46 lines] [quoted text clipped - 13 lines] Any help much appreciated |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to disable/enable command button(ActiveX) using macro | Excel Discussion (Misc queries) | |||
Enable / Disable Command Button depending on a cell's value | Excel Programming | |||
Enable/Disable Command Button | Excel Programming | |||
Enable / Disable a button using a macro | Excel Programming | |||
Enable/Disable Button | Excel Programming |