Running .avi files

D

David

Greetings and TIA for your help
Anyone got VBA code sugestions for opening and running a Windows AVI file from and excel macro? (Would like to run in full screen mode and automatically close and return to Excel at the end of the clip)
 
M

Michel Pierron

Hi David,
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpstrCommand As String _
, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long _
, ByVal hwndCallback As Long) As Long

Sub FullScreenAvi()
Const aviFile = "C:\Clock.avi" ' Modify as appropriate
Dim Cmd As String
Cmd = "play " & aviFile & " fullscreen "
mciSendString Cmd, 0&, 0, 0&
End Sub

Regards;
MP

David said:
Greetings and TIA for your help.
Anyone got VBA code sugestions for opening and running a Windows AVI file from
and excel macro? (Would like to run in full screen mode and automatically close
and return to Excel at the end of the clip)
 
D

David

Michael
Thanks for your respons
When I run this macro nothing happens (no error messages). It just runs & quits without running the .avi file
Would be grateful if you could have another look (does it run ok on your system?
Thanks again
 
M

Michel Pierron

Hi David,
Yes, this macro run ok on my system (Win98 + xl2002) but y only tested it with
small avi (<500ko).
Regards,
MP
 
S

ste mac

Hey guys....

I have been following your thread and the AVI macro is fantastic....

Do you have one that will run in a child window, whereas the spreadsheet
is visible while it runs.... thanks..

seya ste
 
M

Michel Pierron

Hi ste mac,
' In standard module:
Public Play As Boolean
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As String, ByVal uReturnLength _
As Long, ByVal hwndCallback As Long) As Long
Private Returnstring As String

Sub AVI_Play()
Const FileName As String = "c:\mybestfile.avi"
If Dir(FileName) = "" Then Exit Sub
If Play Then AVI_Stop
Returnstring = Space(127)
mciSendString "open " & Chr(34) & FileName & Chr(34) _
& " type avivideo alias video", Returnstring, 127, 0
mciSendString "set video time format ms", Returnstring, 127, 0
mciSendString "play video from 0", Returnstring, 127, 0
Play = True
End Sub

Sub AVI_Stop()
mciSendString "close video", Returnstring, 127, 0
Play = False
End Sub

'In ThisWorkbook module:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Play Then AVI_Stop
End Sub

Regards,
MP
 
S

ste mac

Michel, thankyou very much for you macro, just what I needed...

I will use it right away...

I didn't know you had answered my post! for some reason my page didn't refresh
and I have posted a question based on you macro to this newsgroup, so don't
be surprised if you see another post refeering to your code <g>

Thanks Michel

seeya ste
 
R

ross

Code does not work on m
excel 97 sp
win2000 sp 4
will try at home of diff rig,
nice code though
 
Top