ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Making a sound on condition of textbox (https://www.excelbanter.com/excel-discussion-misc-queries/108456-making-sound-condition-textbox.html)

damorrison

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


Dave Peterson

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

damorrison

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


Dave Peterson

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

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