![]() |
Making a sound on condition of textbox
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 |
Making a sound on condition of textbox
Untested:
With Object("Object 3") .Verb Verb:=xlPrimary End With or just Object("Object 3").Verb Verb:=xlPrimary damorrison wrote: 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 -- Dave Peterson |
Making a sound on condition of textbox
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 |
Making a sound on condition of textbox
How about:
ActiveSheet.OLEObjects("object 3").Verb Verb:=xlPrimary or ActiveSheet.Shapes("Object 3").OLEFormat.Verb Verb:=xlPrimary damorrison wrote: 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 -- Dave Peterson |
Making a sound on condition of textbox
If you wanted a variable.
Dim OLEObj as OLEObject set Oleobj = ActiveSheet.OLEObjects("object 3") oleobj.verb verb:=xlprimary Dave Peterson wrote: How about: ActiveSheet.OLEObjects("object 3").Verb Verb:=xlPrimary or ActiveSheet.Shapes("Object 3").OLEFormat.Verb Verb:=xlPrimary damorrison wrote: 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 -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 02:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com