changing button prop with vba

G

Guest

I have set a buttons enable property to false for startup and am now trying
to enable the button. It is directly on the worksheet and named
btnReconciliation I have tried the following.

Sub EnableReconcil()
ActiveSheet.btnReconciliation.enable = True
'Runtime error 438 Object dosn't support this property or message

ActiveSheet.Buttons("btnReconciliation").enable = True
'Runtime error 1004 unable to get buttons property of the worksheet class

ActiveSheet.OLEObjects("btnReconciliation").enable = True
'Runtime error 1004 unable to get buttons property of the worksheet class
End Sub

any ideas what I could do?
 
G

Guest

You can not use Activesheet. You need to specifically reference the sheet
that the button is on. Something like this...

Sheet1.btnReconciliation.enable = True
 
N

Nigel

Try using Enabled not Enable, also to avoid running the code against the
wrong active sheet specify the sheet explicitly

ActiveSheet.btnReconciliation.Enabled = True

or explicitly

Sheets("Sheet1").btnReconciliation.Enabled = True
 
N

Nigel

Actually that is not true, you can use the activesheet but it is not good
practice, so always reference it explicitly, See my other post for the fix
which is actually a typo which should use Enabled property not enable
 
S

Sandy

Here are a couple of different ways to enable/disable a commandbutton:
From another worksheet:
Worksheets("Sheet2").CommandButton1.Enabled = True

On the current worksheet
CommandButton1.Enabled = False
-or-
ActiveSheet.CommandButton1.Enabled = False


Hope this helps...

Sandy
 
S

Sandy

Here are a couple of different ways to enable/disable a commandbutton:
From another worksheet:
Worksheets("Sheet2").CommandButton1.Enabled = True

On the current worksheet
CommandButton1.Enabled = False
-or-
ActiveSheet.CommandButton1.Enabled = False


Hope this helps...

Sandy
 
S

Sandy

Here are a couple of different ways to enable/disable a commandbutton:
From another worksheet:
Worksheets("Sheet2").CommandButton1.Enabled = True

On the current worksheet
CommandButton1.Enabled = False
-or-
ActiveSheet.CommandButton1.Enabled = False


Hope this helps...

Sandy
 
G

Guest

Nice catch. I missed the typo. I figured that the button was not on the
activesheet which caused the problem... you are absolutely correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top