ShellExecute problem
-
I created an access Lyric database. Then I added a table and a combo to hold song file data. Then, when the user selects a song and clicks play the code below gets executed. When I first did this it went well. WMPlayer opened up and played the song. Now it opens up the open dialog wanting me to select the file. It returns a 42. This is the first time I used this API command. Any help will be appreciated.
Private Sub cmdPlay_Click()
Const klShowApp As Long = 1
Dim sPath As String, sFile As String
Dim lReturn As Long' cboTuneLU has the following columns
' 0 Version ID
' 1 MP3 File
' 2 MP3 PathOn Error GoTo ERR\_cmdPlay\_Click sFile = ksQuote & Me.cboTuneLU.Column(1) & ksQuote sPath = ksQuote & Me.cboTuneLU.Column(2) & ksQuote lReturn = ShellExecute(Me.hWnd, "open", sPath, vbNullString, sFile, klShowApp) Stop ' returns 42
EXIT_cmdPlay_Click:
Exit Sub
ERR_cmdPlay_Click:
'Debug.Print CStr(Err) & " " & Err.Description
ShowError "frmLyrics.cmdPlay_Click"
Resume EXIT_cmdPlay_ClickEnd Sub
-
I created an access Lyric database. Then I added a table and a combo to hold song file data. Then, when the user selects a song and clicks play the code below gets executed. When I first did this it went well. WMPlayer opened up and played the song. Now it opens up the open dialog wanting me to select the file. It returns a 42. This is the first time I used this API command. Any help will be appreciated.
Private Sub cmdPlay_Click()
Const klShowApp As Long = 1
Dim sPath As String, sFile As String
Dim lReturn As Long' cboTuneLU has the following columns
' 0 Version ID
' 1 MP3 File
' 2 MP3 PathOn Error GoTo ERR\_cmdPlay\_Click sFile = ksQuote & Me.cboTuneLU.Column(1) & ksQuote sPath = ksQuote & Me.cboTuneLU.Column(2) & ksQuote lReturn = ShellExecute(Me.hWnd, "open", sPath, vbNullString, sFile, klShowApp) Stop ' returns 42
EXIT_cmdPlay_Click:
Exit Sub
ERR_cmdPlay_Click:
'Debug.Print CStr(Err) & " " & Err.Description
ShowError "frmLyrics.cmdPlay_Click"
Resume EXIT_cmdPlay_ClickEnd Sub
What's the value of sPath and sFile? Those values may not be in the right format. You should probably just pass the file name, and let windows figure out what player to use. Like double clicking on the filename in the folder. https://social.msdn.microsoft.com/Forums/vstudio/en-US/a4de8224-cade-4fda-b304-06d21e970c28/how-to-play-a-mp4-file-using-window-media-player-through-shellexecute-command?forum=vclanguage[^]
-
What's the value of sPath and sFile? Those values may not be in the right format. You should probably just pass the file name, and let windows figure out what player to use. Like double clicking on the filename in the folder. https://social.msdn.microsoft.com/Forums/vstudio/en-US/a4de8224-cade-4fda-b304-06d21e970c28/how-to-play-a-mp4-file-using-window-media-player-through-shellexecute-command?forum=vclanguage[^]
The user actually selects the filespec (path & filename) from the open dialog box. I split the filespec into Path and filename and store each into their corresponding fields in a record. I know the path is correct because the open dialog opens to the correct folder. This was working great, but now It does this. I would sure like to find out what the return values of this API function mean. I tried every number fro 0 to 10 in the show parameter of the shellexecute API call. The record is define as: tblMP3 ------ MP3Seq autonum index MP3ID long MP3VerID integer MP3Path text MP3File text I wanted to be able to save more then one song file. The artist's version and a karaoke version. That's what the MP3VerID is for. The MP3ID field is the same as the autonum field in the lyrics table. I have had this program for a number of years. VB's Shell has been used all this time. But now on Win 7 I get a security message blocking me from using it. That's when I discovered ShellExecute. Any help will be appreciated Roger
-
The user actually selects the filespec (path & filename) from the open dialog box. I split the filespec into Path and filename and store each into their corresponding fields in a record. I know the path is correct because the open dialog opens to the correct folder. This was working great, but now It does this. I would sure like to find out what the return values of this API function mean. I tried every number fro 0 to 10 in the show parameter of the shellexecute API call. The record is define as: tblMP3 ------ MP3Seq autonum index MP3ID long MP3VerID integer MP3Path text MP3File text I wanted to be able to save more then one song file. The artist's version and a karaoke version. That's what the MP3VerID is for. The MP3ID field is the same as the autonum field in the lyrics table. I have had this program for a number of years. VB's Shell has been used all this time. But now on Win 7 I get a security message blocking me from using it. That's when I discovered ShellExecute. Any help will be appreciated Roger