-
Hi there
I'm not terribly advanced in vb, but I've looked through all the help files, and articles, for an answer which I'm sure is very simple.
I simply want to be able to press a command button, which will trigger a file (e.g. "c:\media\mysong.mp3"), to be opened with by its associated application (e.g. "Media Player"). just as what would happen if I went to the file in windows explorer, and double clicked it.
can somebody please come to my rescue. :)
-
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
Dim retVal As Long
retVal = ShellExecute(Me.hwnd, "open", "c:\media\mysong.mp3", vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub
-