Making a sound on condition of textbox

D

damorrison

How can I get this code to work without having to select the object??

Private Sub TextBox1_Change()
If TextBox1 > 24 Then
ActiveSheet.Shapes("Object 3").Select
Selection.Verb Verb:=xlPrimary
Range("F1").Select
End If

End Sub

I tried this but no such luck

Private Sub TextBox1_Change()
Dim Object As Object
If TextBox1 > 24 Then
With Object("Object 3")
Application.Verb Verb:=xlPrimary
End With
End If
End Sub



This object is a sound I inserted, using insert object
 
D

Dave Peterson

Untested:

With Object("Object 3")
.Verb Verb:=xlPrimary
End With

or just
Object("Object 3").Verb Verb:=xlPrimary
 
D

damorrison

Sorry Dave that doesn't work, maybe there is a way to globally name the
object?


it apears, all the examples I found when I searched it, referrs to :

ActiveSheet.Shapes("Object 3").Select
Selection.Verb Verb:=xlPrimary

which sucks because now you have to select the worksheet as well, and
that takes me out of the userform
 
D

Dave Peterson

How about:
ActiveSheet.OLEObjects("object 3").Verb Verb:=xlPrimary

or
ActiveSheet.Shapes("Object 3").OLEFormat.Verb Verb:=xlPrimary
 
D

Dave Peterson

If you wanted a variable.

Dim OLEObj as OLEObject
set Oleobj = ActiveSheet.OLEObjects("object 3")
oleobj.verb verb:=xlprimary
 

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