Userform Combobox plays song in media player based on its value RRS feed

  • Question

  • Need help on this. I have combobox which links to sheet that will show default value based on Column A value. Example,

    A| Twinkle Star | BY Ali

    B| ABC Song | By Kim

    C| 123 Song | By Els

    If i choose A, in userform will shows the twinkle star and by ali in text box. I would like to set if A is chosen, it will play Twinkle Star song, when B is chosen, it wil play ABC Song. Need your opinion please.

    Private Sub UserForm_Initialize()
        Set xRg = Worksheets("Sheet4").Range("A2:C7")
        Me.ComboBox1.List = xRg.Columns(1).Value
    End Sub
    Private Sub ComboBox1_Change()
        Me.TextBox1.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 2, False)
        Me.TextBox2.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 3, False)
        Select Case ComboBox1.Value
           Case "A"
                WindowsMediaPlayer1.Controls.Play= FollowHyperlink "#Sheet4!A2"
           Case "B"
                WindowsMediaPlayer1.Controls.Play= FollowHyperlink "#Sheet4!A3"
        End Select
    End Sub

    i tried using case a, b and links to hyperlink but not works.. appreciate your help guys.

    Tuesday, December 10, 2019 4:39 AM

All replies

  • To:  SES0204
    Re:  playing sounds

    Insert the .wav files into the worksheet (outside the visible range).
    Use Ribbon | Insert (tab) | Text (group) | Object (icon)
    (use the Create from File tab)

    They inserted files should be automatically created with names Object 1, Object 2 and so on
    Use this code to play sounds...  Me.Shapes("Object 1").OLEFormat.Verb

    Above assumes code is in the worksheet module.
    Credit to: Ivan F Moala who posted the above, back in 2007.

    Also, the UserForm initialize event is normally used for housekeeping stuff:  sizing and positioning and so on.

    The free Custom_Functions add-in has 20 new Excel functions including the vLookUpAll function
    Tuesday, December 10, 2019 12:18 PM