Disabling a shape object

  • Thread starter Thread starter groupie
  • Start date Start date
G

groupie

Hi,
have created a SHAPE object, e.g.

Set objbtn = .Shapes.AddFormControl(xlButtonControl, 10, 20, 30, 40)

However would like it disabled by default - how can I set it to this?

Thanks.
 
Untested...
Set objbtn = .Shapes.AddFormControl(xlButtonControl, 10, 20, 30, 40)
objbtn.enabled = false
 
Untested...
Set objbtn = .Shapes.AddFormControl(xlButtonControl, 10, 20, 30, 40)
objbtn.enabled = false

Tested....
....but it didn't work. This property is unknown.
 
Option Explicit
Sub testme()
Dim objBtn As Shape
With ActiveSheet
Set objBtn = .Shapes.AddFormControl(xlButtonControl, 10, 20, 30, 40)
objBtn.OLEFormat.Object.Enabled = False
objBtn.OnAction = "'" & ThisWorkbook.Name & "'!aaa"
End With
End Sub
Sub aaa()
MsgBox "hi"
End Sub

============
I usually go through the buttons collection instead of the Shapes collection.

Option Explicit
Sub testme()
Dim objBtn As Button
With ActiveSheet
Set objBtn = .Buttons.Add(10, 20, 30, 40)
objBtn.Enabled = False
objBtn.OnAction = "'" & ThisWorkbook.Name & "'!aaa"
End With
End Sub
Sub aaa()
MsgBox "hi"
End Sub

It seems easier to me. (as you could tell from my initial (incorrect) guess.)
 

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

Back
Top