Option Explicit
Sub IEProgressExample()
Dim IE, vHead, vBar, i, progr, totl, IEOpen
StartIE IE
Set vHead = IE.Document.All("vHead")
Set vBar = IE.Document.All("vBar")
IEOpen = True
SetProgText vHead, "Working...", IEOpen
totl = 2500
For i = 1 To totl
progr = CLng((i / (totl)) * 100)
SetProgText vBar, String(progr, "|") & String(100 - progr, "."), IEOpen
Next
If IEOpen Then IE.Quit
Set IE = Nothing
Set vHead = Nothing
Set vBar = Nothing
Set IEOpen = Nothing
Set i = Nothing
Set progr = Nothing
Set totl = Nothing
End Sub
Function SetProgText(ByVal vDocumentObject, ByVal vObjectText, ByRef IEOpen)
If Not IEOpen Then Exit Function
On Error Resume Next
vDocumentObject.InnerHTML = vObjectText
If Err.Number <> 0 Then IEOpen = False
Set vObjectText = Nothing
Set vDocumentObject = Nothing
End Function
Function StartIE(ByRef IE)
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Navigate2 "about:blank"
Do While .readyState <> 4
Loop
.Document.Title = "Progress"
.Document.Body.InnerHTML = _
"<BODY SCROLL='NO'><CENTER><FONT FACE='arial black' SIZE=2>" & vbLf & _
"<DIV id='vHead' ALIGN='Left'></DIV>" & vbLf & _
"<DIV id='vBar' ALIGN='Left'></DIV>" & vbLf & _
"</FONT></CENTER></BODY>"
.Document.Body.Scroll = "no"
.Toolbar = False
.StatusBar = False
.Resizable = False
.Width = 435
.Height = 100
.Left = 0
.Top = 0
.Visible = True
End With
End Function
|