時間のかかるバッチ処理を実行状態を見たい時などに利用
Option Explicit
Dim objIE
Dim i
'IEオブジェクト.
Set objIE = Createobject( "InternetExplorer.Application" )
' 初期化.
Call InitProgressbar()
' 実行.
For i = 1 To 100
Call ActionProgressbar( 100 , i )
WScript.Sleep(10) ' 10msec間隔で更新.
Next
' 終了.
objIE.Quit
Set objIE = Nothing
'====== 初期化 ======.
Function initProgressbar()
'初期ページを表示します
objIE.Navigate "about:blank"
'ページを表示します
objIE.Document.Write "<html>"
objIE.Document.Write "<head>"
objIE.Document.Write "<title>プログレスバー</title>"
objIE.Document.Write "</head>"
objIE.Document.Write "<body bgcolor='#0c0c0c'>"
objIE.Document.Write "<table border=0 width='100%' height='100%'>"
objIE.Document.Write " <tr>"
objIE.Document.Write " <td align='left' width='80%'>"
objIE.Document.Write " <hr id='progressbar' style='height=50;width=0;color:#fcfcfc;'>"
objIE.Document.Write " </td>"
objIE.Document.Write " <td align='right' width='20%'>"
objIE.Document.Write " <span id='per' style='color:#fcfcfc;'>0 %</span><br>"
objIE.Document.Write " </td>"
objIE.Document.Write " </tr>"
objIE.Document.Write "</table>"
objIE.Document.Write "</body>"
objIE.Document.Write "</html>"
'IEの表示設定.
objIE.Width = 300
objIE.Height = 50
objIE.AddressBar = False
objIE.MenuBar = False
objIE.ToolBar = False
objIE.Resizable = False
objIE.Statusbar = False
objIE.Visible = True
End Function
'====== 実行 ======.
Function ActionProgressbar( pMax, pCnt )
Dim perValue
Dim progValue
Dim i
perValue = Int( pCnt / pMax * 100 )
progValue = perValue * 2
objIE.Document.all( "progressbar" ).style.width = progValue
objIE.Document.all( "per" ).InnerText = perValue & " %"
End Function