LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Running a gif in an html window

Thanks, Steve. I am going try this out. I so appreciate your help.

Lynn

"Steve Yandl" wrote:

Lynn,

I decided to play with this a bit and came up with something that might work
for you. The subroutine below that I named Showcase takes two arguments,
the name of the gif including the file path and an optional argument for the
number of seconds you want it to run. If you leave off the optional
argument, it runs for 15 seconds. When launched, the sub checks that the
animated gif file exists and then determines its height and width. A
temporary hta file is created that presents a window with no title bar, no
scroll bar and the exact dimensions to display the animated gif. The
temporary hta is launched for the specified time period and the file itself
is deleted from the temp folder.

To call the subroutine, you could use a different three line sub like this:
___________________________________

Sub LaunchTest()
Showcase ("C:\Test\Animated.gif", 30)
End Sub
__________________________________



Here is the actual sub

_________________________________

Sub Showcase(strFileToChk As String, Optional intDur As Integer = 15)

Const filePropName = 0
Const filePropDimensions = 26

Dim retVal
Dim w As String ' integer representing width considered as text string
Dim h As String ' integer representing height considered as text string

Set FSO = CreateObject("Scripting.FileSystemObject")

' Check the animated picture file exists and get its dimensions
If FSO.FileExists(strFileToChk) Then
Set objShell = CreateObject("Shell.Application")
strArgParent = FSO.GetParentFolderName(strFileToChk)
strArgFileName = FSO.GetFileName(strFileToChk)
Set objFolder = objShell.Namespace(strArgParent)

For Each strFileName In objFolder.Items
If objFolder.GetDetailsOf(strFileName, filePropName) =
strArgFileName Then
strDimensions = objFolder.GetDetailsOf(strFileName,
filePropDimensions)
End If
Next

If InStr(strDimensions, " x ") 0 Then
sizeArr = Split(strDimensions, "x")
w = Trim(sizeArr(0))
h = Trim(sizeArr(1))
End If
Else
Set FSO = Nothing
Exit Sub
End If

' Create an HTA file to show the animated file from
strHTAname = FSO.GetSpecialFolder(2) & "\Temp0.hta"
Set txtHTA = FSO.CreateTextFile(strHTAname)

With txtHTA
.WriteLine "<HTML"
.WriteLine "<HTA:Application"
.WriteLine "Caption=" & Chr(34) & "no" & Chr(34)
.WriteLine "Scroll=" & Chr(34) & "no" & Chr(34) & ""
.WriteLine "<SCRIPT Language=" & Chr(34) & "VBScript" & Chr(34) & ""
.WriteLine "Sub Window_OnLoad"
.WriteLine "window.resizeTo " & w & ", " & h
.WriteLine "idTimer = window.setTimeout(" & Chr(34) & "CloseShop" &
Chr(34) _
& ", " & CStr(intDur * 1000) & ", " & Chr(34) & "VBScript" & Chr(34) &
")"
.WriteLine "End Sub"
.WriteLine "Sub CloseShop"
.WriteLine "window.clearTimeout(idTimer)"
.WriteLine "self.close()"
.WriteLine "End Sub"
.WriteLine "</SCRIPT"
.WriteLine "<BODY background=" & Chr(34) & strFileToChk & Chr(34) & ""
.WriteLine "</BODY"
.WriteLine "</HTML"
.Close
End With

' Run the new HTA file
retVal = Shell("mshta.exe " & strHTAname, vbNormalFocus)

' Delete the HTA file from the Temp folder
FSO.DeleteFile strHTAname

Set objShell = Nothing
Set FSO = Nothing
End Sub

________________________________

Steve



"Lynn" wrote in message
...
Does anyone know if it is possible to run an animated gif through an html
window via Excel VBA while the Excel macro continues to run?

Thanks.






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel2000 running but window is gone K C Excel Discussion (Misc queries) 0 April 9th 09 07:54 PM
Running Macro minimises window PaulW Excel Discussion (Misc queries) 1 April 19th 06 04:49 PM
How can I hide VBE window appearing when running VB6 app vivek7 Excel Programming 0 March 23rd 06 05:39 PM
Running URL using VBA - but not displaying IE window matpj[_37_] Excel Programming 2 February 9th 06 11:01 AM
Running macro in a browser window Ted Theodoropoulos Excel Programming 1 August 4th 03 08:24 PM


All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"