DaveNoviceVB
asked on
URGENT: HTML slideshow in VBA
I have a directory of HTML files, which I want to show as a slideshow, written in VBA for Excel. The HTML files were created as Excel workbooks, saved as HTML format.
The structure is as follows:
workbook1 is saved as: name1.html
this then creates an html file for each worksheet in the original workbook... i.e:
worksheets 1 and 2 are saved as:
name1/sheet001.html
name2/sheet002.html ......
Q. how do I create a slide show, looping thru every sheet00x.html, with a 30 second delay between html file displays???
Many thanks,
Dave
The structure is as follows:
workbook1 is saved as: name1.html
this then creates an html file for each worksheet in the original workbook... i.e:
worksheets 1 and 2 are saved as:
name1/sheet001.html
name2/sheet002.html ......
Q. how do I create a slide show, looping thru every sheet00x.html, with a 30 second delay between html file displays???
Many thanks,
Dave
ASKER
I want to use VBA for Excel - any ideas??
Please maintain this equally "URGENT" and open question:
URGENT: VB helpfile in Excel 2000 not working Date: 02/14/2002 02:33AM PST
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20266715
Thanks,
Anthony
PS There is no need to put URGENT in all your questions. It does not expedite the answer any more than maintaining your open questions.
URGENT: VB helpfile in Excel 2000 not working Date: 02/14/2002 02:33AM PST
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20266715
Thanks,
Anthony
PS There is no need to put URGENT in all your questions. It does not expedite the answer any more than maintaining your open questions.
Well, first of all, you need a timer.
place the following code in a module:
Option Explicit
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Public TimerID As Long
Public Function TimerEnable(ByVal hWnd As Long, _
ByVal mSecs As Long) As Long
TimerEnable = SetTimer(hWnd, TimerID, mSecs, _
AddressOf TimerFired)
End Function
Public Function TimerDisable(ByVal hWnd As Long) As Long
TimerDisable = KillTimer(hWnd, TimerID)
End Function
Private Sub TimerFired(ByVal hWnd As Long, _
ByVal TimerID As Long, ByVal IDEvent As Long, _
ByVal dwTime As Long)
Debug.Print "Fired "; hWnd; TimerID; IDEvent; Time 'dwTime
End Sub
place the following code in a module:
Option Explicit
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Public TimerID As Long
Public Function TimerEnable(ByVal hWnd As Long, _
ByVal mSecs As Long) As Long
TimerEnable = SetTimer(hWnd, TimerID, mSecs, _
AddressOf TimerFired)
End Function
Public Function TimerDisable(ByVal hWnd As Long) As Long
TimerDisable = KillTimer(hWnd, TimerID)
End Function
Private Sub TimerFired(ByVal hWnd As Long, _
ByVal TimerID As Long, ByVal IDEvent As Long, _
ByVal dwTime As Long)
Debug.Print "Fired "; hWnd; TimerID; IDEvent; Time 'dwTime
End Sub
Could you try this?
'NOTE: replace first sPath variable with your choice
Option Explicit
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Public TimerID As Long
Dim arrFolders() As String
Dim arrFiles() As String
Sub main()
Dim ffile As String, ffolder As String
Dim sPath As String
Dim idx As Integer
sPath = "c:\"
ffolder = Dir$(sPath & "\*.*", vbDirectory)
Do While ffolder <> ""
If (ffolder <> "." And ffolder <> "..") Then
ReDim Preserve arrFolders(idx)
arrFolders(idx) = sPath & "\" & ffolder
idx = idx + 1
End If
Loop
idx = 0
For idx = 0 To UBound(arrFolders) - 1
sPath = arrFolders(idx)
ffile = Dir$(sPath & "\*.htm", vbArchive)
Do While ffile <> ""
ReDim Preserve arrFiles(idx)
arrFiles(idx) = sPath & "\" & ffile
Loop
Next idx
TimerEnable 0, 30000
End Sub
Public Function TimerEnable(ByVal hWnd As Long, _
ByVal mSecs As Long) As Long
TimerEnable = SetTimer(hWnd, TimerID, mSecs, _
AddressOf TimerFired)
End Function
Public Function TimerDisable(ByVal hWnd As Long) As Long
TimerDisable = KillTimer(hWnd, TimerID)
End Function
Private Sub TimerFired(ByVal hWnd As Long, _
ByVal TimerID As Long, ByVal IDEvent As Long, _
ByVal dwTime As Long)
' this error is necesary only the first time
On Error Resume Next
Static shItem As Long
If shItem <= UBound(arrFiles) Then
With Application
.Workbooks(shItem).Saved = True
.Workbooks(shItem).Close
.Open arrFiles(shItem)
End With
shItem = shItem + 1
Else
TimerDisable 0
End If
End Sub
'NOTE: replace first sPath variable with your choice
Option Explicit
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Public TimerID As Long
Dim arrFolders() As String
Dim arrFiles() As String
Sub main()
Dim ffile As String, ffolder As String
Dim sPath As String
Dim idx As Integer
sPath = "c:\"
ffolder = Dir$(sPath & "\*.*", vbDirectory)
Do While ffolder <> ""
If (ffolder <> "." And ffolder <> "..") Then
ReDim Preserve arrFolders(idx)
arrFolders(idx) = sPath & "\" & ffolder
idx = idx + 1
End If
Loop
idx = 0
For idx = 0 To UBound(arrFolders) - 1
sPath = arrFolders(idx)
ffile = Dir$(sPath & "\*.htm", vbArchive)
Do While ffile <> ""
ReDim Preserve arrFiles(idx)
arrFiles(idx) = sPath & "\" & ffile
Loop
Next idx
TimerEnable 0, 30000
End Sub
Public Function TimerEnable(ByVal hWnd As Long, _
ByVal mSecs As Long) As Long
TimerEnable = SetTimer(hWnd, TimerID, mSecs, _
AddressOf TimerFired)
End Function
Public Function TimerDisable(ByVal hWnd As Long) As Long
TimerDisable = KillTimer(hWnd, TimerID)
End Function
Private Sub TimerFired(ByVal hWnd As Long, _
ByVal TimerID As Long, ByVal IDEvent As Long, _
ByVal dwTime As Long)
' this error is necesary only the first time
On Error Resume Next
Static shItem As Long
If shItem <= UBound(arrFiles) Then
With Application
.Workbooks(shItem).Saved = True
.Workbooks(shItem).Close
.Open arrFiles(shItem)
End With
shItem = shItem + 1
Else
TimerDisable 0
End If
End Sub
Hi,
I had an interesting suggestion (using references), but I don't want to put any effort for people who want others to solve their problems just for kicks.
Enjoy
I had an interesting suggestion (using references), but I don't want to put any effort for people who want others to solve their problems just for kicks.
Enjoy
ASKER
Richie,
thanks VERY much for your response - I'll try it and get back to you as soon as I can. The reason I didn't post any code is because I am new to VB and want to learn, but didn't know where to start.
Thanks again Richie,
Dave
thanks VERY much for your response - I'll try it and get back to you as soon as I can. The reason I didn't post any code is because I am new to VB and want to learn, but didn't know where to start.
Thanks again Richie,
Dave
ASKER
I will not be posting URGENT again in the title.
Dave
Dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To sort Arrfiles array, you could see:
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=10
Just a question: Why do you need to slide those files in Excel?
With Automation you could slide them in Internet Explorer. If you change your mind, i have the code to do it with IE.
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=10
Just a question: Why do you need to slide those files in Excel?
With Automation you could slide them in Internet Explorer. If you change your mind, i have the code to do it with IE.
ASKER
I've hit a stumbling block - when opening the \sheet00x.html file, it always defaults back to what was the 1st worksheet in the workook - despite clicking the sheet00x.html file. ANy ideas how to change this??
How do you automate in IE?? Maybe better fix. I wanted to do it in VBA just so I can use it to pickup alll html files in a directory and produce the slideshow automatically.
Thanks alot for your help so far. I didn't know I could offend so many people with 1 question.
How do you automate in IE?? Maybe better fix. I wanted to do it in VBA just so I can use it to pickup alll html files in a directory and produce the slideshow automatically.
Thanks alot for your help so far. I didn't know I could offend so many people with 1 question.
You could manage Internet Explorer with VBA (from Excel,Word, etc).
"...
I've hit a stumbling block - when opening the \sheet00x.html file, it always defaults back to what was
the 1st worksheet in the workook - despite clicking the sheet00x.html file. ANy ideas how to change
this??
...."
Sorry, i didn't understand that. How many sheets were in each workbook?
"...
I've hit a stumbling block - when opening the \sheet00x.html file, it always defaults back to what was
the 1st worksheet in the workook - despite clicking the sheet00x.html file. ANy ideas how to change
this??
...."
Sorry, i didn't understand that. How many sheets were in each workbook?
Hi DaveNoviceVB,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept Richie_Simonetti's comment(s) as an answer.
DaveNoviceVB, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept Richie_Simonetti's comment(s) as an answer.
DaveNoviceVB, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange
Better use powerpoint for slideshows the viewer is free, or would you like to use excel for a slideshow? never looked at it that way
:O)Bruintje