Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Playing a music file

Status
Not open for further replies.

locosh

Technical User
Nov 12, 2001
9
0
0
US
Hello everyone,

I am trying to use a command button to play an MP3 file through Windows Media Player.

The button will be used in a form, and the file I would like to play is inside a field called Filename in the form.
Filename describes the path to the music file (ie. c:\music\3 doors down - kryptonite.mp3)

The code I have is:

****************************************************
Private Sub Play_File_Click()
On Error GoTo Err_Play_File_Click

Dim stAppName As String

stAppName = "C:\Program Files\Windows Media Player\wmplayer.exe /play " & Me![Filename]
Call Shell(stAppName, 1)

Exit_Play_File_Click:
Exit Sub

Err_Play_File_Click:
MsgBox Err.Description
Resume Exit_Play_File_Click

End Sub
*******************************************************

However, it doesn't play the current file in the field Filename, in fact it doesn't play anything. I am not a big programming fan, so I am a bit stuck here. I suspect it has something to do with the spaces in the filename path (ie. 3 doors down - kryptonite.mp3)

Help!
 
Try to change this line:

stAppName = "C:\Program Files\Windows Media Player\wmplayer.exe /play " & Me![Filename]

become:

stAppName = "C:\Program Files\Windows Media Player\wmplayer.exe /play " & """" & Me![Filename] & """"
 
Excellent !!

Thanks Ryanku, it works like a charm.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top