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!

Runnig file from command

Status
Not open for further replies.

ViperInc

Programmer
Mar 13, 2001
24
0
0
AU
hi...

Just a quick one...
I want to run a movie file in WMP(Windows Media Player) from clicking a button.
The button is pressed, a dialog box opens, and a movie is selected. Ok is pressed and up opens WMP and the movie plays.
Only things is the coding I have done doesn't work.
I can get it to play the movie using a destop shortcut, but vb wont reconise the command properly.

This is my code so far...

Private Sub lblPlay_Click()
On Error GoTo Cancel
Dim openMovie
Dim movie As String
cdbmovie.Filter = "DivX Movie | *.avi"
cdbmovie.ShowOpen
movie = cdbmovie.FileName
openMovie = "C:\Program Files\Windows Media Player\wmplayer.exe" & """ """ & movie

'MsgBox "test", vbInformation, "test"
Unload Me
End
Exit Sub

I don't understnad why it wont work...
If any one has any idea, it would be great....
thanx...
 
Viper,
You can try this:

Code:
Private Sub lblPlay_Click()
Dim myMovie
Dim movieName As String
movieName = InputBox("Enter filepath of movie.")
myMovie = Shell( _
  "C:\Program Files\Windows Media Player\mplayer2.exe" _
  & " " & movieName, 1)
Exit Sub

I used the input box to get the filepath for the movie. You can use a combo box or whatever.

Hope this helps,
--tbuch
 
thanx, but this didnt work...
I orignally used this code and then tried to modify it to work with wmplayer.
it seems the the new player doesnt like to be run like this, as with other players this works.

you can run a shortcut style command from vb, it would be great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top