Making a sound on condition of textbox

  • Thread starter Thread starter damorrison
  • Start date Start date
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
 
Untested:

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

or just
Object("Object 3").Verb Verb:=xlPrimary
 
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
 
How about:
ActiveSheet.OLEObjects("object 3").Verb Verb:=xlPrimary

or
ActiveSheet.Shapes("Object 3").OLEFormat.Verb Verb:=xlPrimary
 
If you wanted a variable.

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