PDA

View Full Version : Macro to move from windows media player to an Excel worksheet



atuchi
10-24-2017, 06:41 PM
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.

SamT
10-25-2017, 02:25 PM
bump

reyreyreyes
10-26-2017, 12:52 PM
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)

atuchi
10-26-2017, 07:53 PM
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?

reyreyreyes
10-27-2017, 12:38 AM
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.

atuchi
10-27-2017, 04:06 PM
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.

reyreyreyes
10-28-2017, 12:50 AM
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...?