Skip to content

Instantly share code, notes, and snippets.

Created March 22, 2012 22:26
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Option Explicit
'Microsoft HTML Object Library
Private d As MSHTML.HTMLDocument
Private w As MSHTML.IHTMLWindow2
Private TimerId As Long
Public Sub Sample()
Call StartTimer
MsgBox "タイマー処理を開始しました。" & vbCrLf & _
"タイマーID:" & TimerId, vbInformation + vbSystemModal
Call EndTimer
MsgBox "タイマー処理を終了しました。", vbInformation + vbSystemModal
End Sub
Public Sub StartTimer()
If TimerId <> 0& Then Exit Sub
Set d = New MSHTML.HTMLDocument
Set w = d.parentWindow
w.onhelp = Me
TimerId = w.setInterval("onhelp.TimerProc", 10&, "VBScript")
Debug.Print "--- タイマー開始 --- (" & Hex(TimerId) & ")" '確認用
End Sub
Public Sub EndTimer()
If TimerId = 0& Then Exit Sub
Call w.clearInterval(TimerId)
TimerId = 0&
Set d = Nothing
Debug.Print "--- タイマー終了 ---" '確認用
End Sub
Public Sub TimerProc()
Static n As Long
n = n + 1
ActiveSheet.Range("A1").Value = n
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment