PDA

View Full Version : Image Slide Show



gibbo1715
12-17-2007, 02:53 AM
Hi All

Been a while

I would like to make an image slide show using vba and call it from excel but im having problems with my code (Example below is me trying my hand at vbscript though), can anyone tell me what is wrong with this code please as i just get a blank ie screen and generate an error

thanks

gibbo

On Error Resume Next
Dim objFSO, oFO, oFolder, oFile, picDir, IE, Locus
Set objFSO = CreateObject("Scripting.FileSystemObject")
picDir = "C:\Documents and Settings\HP_Owner\Desktop\Slideshow\pics\"
Set oFolder = objFSO.GetFolder(picDir)
Set IE = CreateObject("InternetExplorer.Application")
IE.toolbar = false : IE.menubar = false : IE.statusbar = false : IE.Resizable = False

For Each oFile In oFolder.Files
If Right(oFile.Name,3) = "jpg" Or Right(oFile.Name,3) = "gif" Then

Locus = "file://" & Replace(oFile.ParentFolder,"\","/")&"/" & oFile.Name

With IE.document
.Open
.WriteLn "<HTML><HEAD>"
.WriteLn "<TITLE>HELLO!</TITLE></HEAD>"
.WriteLn "<BODY>"
.WriteLn "Hello world"
.WriteLn "<img src='" & Locus & "'><br>"
IE.Visible = True
WScript.Sleep 5000
.WriteLn "</BODY>"
.WriteLn "</HTML>"
.Close
End With
IE.Visible = True
WScript.Sleep 5000
End If
Next
Set IE = Nothing
Set objFSO = Nothing

gibbo1715
12-17-2007, 03:42 AM
Got to the next stage with this as below, would still like to be able to add some Forward Back Start and Stop Buttons though if any one has any ideas

thanks

gibbi


On Error Resume Next
Dim objFSO, oFO, oFolder, oFile, picDir, IE, Locus
Set objFSO = CreateObject("Scripting.FileSystemObject")
picDir = "C:\Documents and Settings\HP_Owner\Desktop\Slideshow\pics\"
Set oFolder = objFSO.GetFolder(picDir)
Set IE = CreateObject("InternetExplorer.Application")
With IE
.menubar=0
.toolbar=0
.statusBar=0
.navigate "About:Blank"
End With
'wait a while until IE as finished to load
Do while IE.busy
loop

For Each oFile In oFolder.Files
If Right(oFile.Name,3) = "jpg" Or Right(oFile.Name,3) = "gif" Then
Locus = "file://" & Replace(oFile.ParentFolder,"\","/")&"/" & oFile.Name
With IE.document
.Open
.WriteLn "<HTML><HEAD>"
.WriteLn "<TITLE>Slide Show</TITLE></HEAD>"
.WriteLn "<BODY>"
.WriteLn "Hello world<br><Br>"
.WriteLn "<img src='" & Locus & "'><br>"
.WriteLn "</BODY>"
.WriteLn "</HTML>"
.Close
End With
IE.Visible = True
WScript.Sleep 2000
End If
Next

Set IE = Nothing
Set objFSO = Nothing
WScript.Quit(0)