| 
    
     |  | こんにちは。かみちゃん です。 
 >Webクエリを
 >.RefreshPeriod = 1
 >などで、「定期的に更新する」(この例では1分間隔)タイミングを捉えることで
 >いいでしょうか?
 
 この件であれば、私は、以下のようにしています。
 
 '■標準モジュール
 Private wbes() As Class1
 
 Sub Macro1()
 Dim strURL As String
 ReDim wbes(1)
 
 Set wbes(0) = New Class1
 
 '(xxxxは、httpを半角にします)
 strURL = "xxxx://www.vbalab.net/vbaqa/c-board.cgi?id=excel"
 
 With ActiveSheet.QueryTables.Add(Connection:="URL;" & strURL, _
 Destination:=Range("A1"))
 .WebSelectionType = xlAllTables   'ページ全体
 .WebFormatting = xlWebFormattingNone '取り込み形式は指定なし
 .RefreshPeriod = 1 '★1分間隔で更新する
 .Refresh BackgroundQuery:=False
 End With
 Set wbes(0).wq = ActiveSheet.QueryTables(1)
 End Sub
 
 '起動したいマクロ名
 Sub Macro1_1(ByVal w As Excel.Worksheet)
 MsgBox "Macro1_1が起動しました"
 End Sub
 
 '■クラスモジュール モジュール名 Class1
 Private WithEvents wb As Excel.QueryTable
 
 Property Set wq(ByVal tmp As Excel.QueryTable)
 Set wb = tmp
 End Property
 
 Private Sub wb_AfterRefresh(ByVal Success As Boolean)
 If Success Then
 Call Macro1_1(wb.ResultRange.Worksheet) '起動したいマクロ名
 End If
 End Sub
 
 |  |