Consulting

Results 1 to 7 of 7

Thread: Macro to move from windows media player to an Excel worksheet

  1. #1
    VBAX Newbie
    Joined
    Oct 2017
    Posts
    3
    Location

    Macro to move from windows media player to an Excel worksheet

    I need help to create a macro that would move me back to an existing Excel worksheet. I've created a program that plays an MP3 song on windows media player and the user must click on one of four macro buttons to name the song. The problem is that the player must first click anywhere on the Excel worksheet before being able to click on the button to name the song. I have used "'ActiveWorkbook.Worksheets("Sheet1").Select", "Sheets("Sheet1").Select" and "Sheets("Sheet1").Activate" and none of those lines gets me back to the worksheet. I would like to eliminate the current need to essentially double click to run the macro button.

    Any assistance is greatly appreciated. Thank you.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    bump
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Quote Originally Posted by atuchi View Post
    I need help to create a macro that would move me back to an existing Excel worksheet. I've created a program that plays an MP3 song on windows media player and the user must click on one of four macro buttons to name the song. The problem is that the player must first click anywhere on the Excel worksheet before being able to click on the button to name the song. I have used "'ActiveWorkbook.Worksheets("Sheet1").Select", "Sheets("Sheet1").Select" and "Sheets("Sheet1").Activate" and none of those lines gets me back to the worksheet. I would like to eliminate the current need to essentially double click to run the macro button.

    Any assistance is greatly appreciated. Thank you.
    How about adding this after the code that plays the song:

    AppActivate(ThisWorkbook.Name)

  4. #4
    VBAX Newbie
    Joined
    Oct 2017
    Posts
    3
    Location
    Thanks. Here is my coding with your addition:

    ActiveWorkbook.Worksheets("Sheet2").Select
    Range("A" & SongRow).Hyperlinks(1).Follow 'Play the selected song
    AppActivate ("Sheet1") 'I previously had this [Sheets("Sheet1").Select] on this line.
    Range("D12").Select

    After starting the song, which is on Sheet 2, the macro does not move me to Sheet 1. Did I do the change correctly?

  5. #5
    Quote Originally Posted by atuchi View Post
    Thanks. Here is my coding with your addition:

    ActiveWorkbook.Worksheets("Sheet2").Select
    Range("A" & SongRow).Hyperlinks(1).Follow 'Play the selected song
    AppActivate ("Sheet1") 'I previously had this [Sheets("Sheet1").Select] on this line.
    Range("D12"). Select
    Literally type what I wrote in my previous post, instead of referring to "Sheet1". Try that! It works for me with an instance of IE, but I can't test any more at the mo as away from computer.

  6. #6
    VBAX Newbie
    Joined
    Oct 2017
    Posts
    3
    Location
    Reyreyreyes:
    Thanks again for your consideration. I made the changes per your reply, but unfortunately I could not get the process to work. The macro left me on Sheet2 rather than moving to Sheet1. I also tried setting up everything on Sheet1 so that moving from one sheet to another was eliminated and used your recommended code, but no luck. Aloha from Hawaii.

  7. #7
    If you are at the point where you are being brought back to Excel, you should be able to active sheet 1...

    ThisWorkbook.Sheets("Sheet1").Activate
    This is assuming you are returned to Excel after beginning your MP3...?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •