View Full Version : [SOLVED:] Play Movie in Excel
thekneeguy
09-20-2005, 06:01 AM
Hello,
I am trying to use a command button on a user form to execute the Windows Media Player to play a .mov file. I will post what I have tried but I think it is a combination of a couple of peoples' ideas so it might confuse you worse than me.
I am wondering (because I have received conflicting information) - Do I need a public declaration statement? I have tried this
Public declaration in a module:
Public Declare Function sndPlaySound32 Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Then for the CommandButton12_Click() statement I have tried
Call sndPlaySound32("c:\Documents and Settings\Richard.RICHARD-A0238C\My Documents\DePuy Project\InsertMovie.MOV")
At one point this was close I think because I was hearing a little "ding" noise but it did not play the file.
Another guy suggested I try a CreateObject but it kept giving me "run" method failure compiler errors.
Could someone PLEASE help me out this is my last part of my project.
Thank you very much!
Marcster
09-20-2005, 06:25 AM
Hi thekneeguy,
Not sure if sndPlaySound32 plays .MOV or not though :dunno .
I think sndPlaySound32 plays .WAV files only and not .MOV files.
This will play the applause sound (tested with Excel 2000 on Windows XP Pro):
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Call sndPlaySound32("C:\WINNT\Media\Microsoft Office 2000\applause.wav",0)
Marcster.
Marcster
09-20-2005, 07:31 AM
To look at the Windows Media Player's objects and propereties,
have a look at:
msdxm.ocx
wmp.dll
in the VBE object browser.
Killian
09-20-2005, 08:00 AM
OK well sndPlaySound32, As Marc says, just plays sounds.
What you're saying is you want to launch a movie (rather than have one playing in an embedded palyer in the worksheet)?
A couple of points:
1. MOV files require QuickTime to play
2. If you have QuickTime installed, this code will do it (change the paths as appropriate)
Const strMOVEXEPATH As String = "C:\Program Files\QuickTime\QuickTimePlayer.exe "
Const strMOVFILEPATH As String = "C:\Program Files\QuickTime\Sample.mov"
Dim shellcommand As String
shellcommand = strMOVEXEPATH & " " & """" & strMOVFILEPATH & """"
Shell shellcommand, vbNormalFocus
Bob Phillips
09-20-2005, 08:17 AM
Shell "C:\Program Files\Windows Media Player\wmplayer.exe /play /fullscreen /close ""c:\Documents and Settings\Richard.RICHARD-A0238C\My Documents\DePuy Project\InsertMovie.MOV""", 1
thekneeguy
09-20-2005, 08:47 AM
Thank you for your responses. Just to clarify .... is
Const strMOVEXEPATH As String = "C:\Program Files\QuickTime\QuickTimePlayer.exe "
Const strMOVFILEPATH As String = "C:\Program Files\QuickTime\Sample.mov"
Dim shellcommand As String
supposed to go in a public module
shellcommand = strMOVEXEPATH & " " & """" & strMOVFILEPATH & """"
Shell shellcommand, vbNormalFocus
and then fo the private declaration this?????
shellcommand = strMOVEXEPATH & " " & """" & strMOVFILEPATH & """"
Shell shellcommand, vbNormalFocus
THank you for this direction!!!!!!!!!!
Killian
09-20-2005, 09:47 AM
Paste this into a standard module and run the PlayMovie routine
'declarations at the top of a standard module
Const strMOVEXEPATH As String = "C:\Program Files\QuickTime\QuickTimePlayer.exe "
Const strMOVFILEPATH As String = "C:\Program Files\QuickTime\Sample.mov"
then a subroutine
Sub PlayMovie()
Dim shellcommand As String
shellcommand = strMOVEXEPATH & " " & """" & strMOVFILEPATH & """"
Shell shellcommand, vbNormalFocus
End Sub
Bob Phillips
09-20-2005, 10:26 AM
Just add this code to the userform, no need for any declaration
Private Sub CommandButton1_Click()
Const strMOVEXEPATH As String = "C:\Program Files\QuickTime\QuickTimePlayer.exe "
Const strMOVFILEPATH As String = "C:\Program Files\QuickTime\Sample.mov"
Dim shellcommand As String
shellcommand = strMOVEXEPATH & " " & """" & strMOVFILEPATH & """"
Shell shellcommand, vbNormalFocus
End Sub
thekneeguy
09-21-2005, 03:36 PM
Thanks to all that posted! I got it thank you very very much!
Killian
09-21-2005, 03:41 PM
Good to here it's worked out :thumb
I've marked the thread as solved...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.