View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ste mac ste mac is offline
external usenet poster
 
Posts: 117
Default ThisWorkbook.Path & "\" & .... not WAVFile, but AVI file...

Hi there... I got this code from somewhere (apologies for not knowing who)
I would like to alter it so if the .avi file was in the same directory
the .xls file...it would play the avi....
I have a xl file that plays a .wav file and the syntax looks like this:
WAVFile = "dogbark.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
but I cannot get it to work in the code below.
So as long as the required .wav file is in the same folder as the xl book
it finds and plays the file can this also be done to the code below?

many thanks

seeya ste

Option Explicit

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _
lpstrCommand As String, ByVal lpstrReturnStr As Any, ByVal wReturnLen _
As Long, ByVal hCallBack As Long) As Long
Declare Function GetActiveWindow Lib "USER32" () As Integer
Const WS_CHILD = &H40000000

Sub PlayAVIFile()

Dim CmdStr As String, FileSpec As String
Dim Ret As Integer, XLSHwnd As Integer
FileSpec = "C:\windows\clock.avi"
XLSHwnd = GetActiveWindow()
CmdStr = ("open " & FileSpec & _
" type AVIVideo alias animation parent " & _
LTrim$(Str$(XLSHwnd)) & " style " & LTrim$(Str$(WS_CHILD)))
Ret = mciSendString(CmdStr, 0&, 0, 0)
Ret = mciSendString("put animation window at 80 170 370 370", _
0&, 0, 0)
Ret = mciSendString("play animation wait", 0&, 0, 0)
Ret = mciSendString("close animation", 0&, 0, 0)

End Sub