|    | 
     ▼困惑 さん、こんばんわ、ちんといいます。 
5秒は時間的に短いとおもいますが。(WEBの表示などに時間がかかると5秒では短い) 
あくまでもサンプルとして、SENDKEYを使用します。 
タイトルもしくはアドレスが変更されていない時、「最新情報に更新する」です。 
※Excelを終了しないと永遠に実行しますので、注意ください。 
ただし、CPU負荷はそれほどでもないです。 
Application.OnTime で設定した時間後とに起動します。 
 
Option Explicit 
Public IE   As Object 
Public strURL As String 
Public lngRet As Long 
Public Ie_locationName As Variant 
Public Ie_locationURL As Variant 
Private Declare Function SetForegroundWindow Lib "user32.dll" ( _ 
  ByVal hWnd As Long _ 
) As Long 
 
 
Sub Sample() 
  
  Const READYSTATE_COMPLETE = &H4 
  
  strURL = "ht tp://www.yahoo.co.jp" 
   
  Set IE = CreateObject("InternetExplorer.application") 
  IE.Visible = True 
  IE.navigate strURL 
  Do 
    DoEvents 
  Loop Until Not IE.Busy And IE.readyState = READYSTATE_COMPLETE 
  
  ' IE のウインドウをアクティブにする 
  lngRet = SetForegroundWindow(IE.hWnd) 
  If lngRet <> 0 Then 
   Ie_locationName = IE.locationname  '*** 現在のタイトルを取得 
   Ie_locationURL = IE.locationURL   '*** 現在のURLを取得 
   
  End If 
   
  Application.OnTime Now + TimeValue("00:00:05"), "AlarmMessage" 
 
End Sub 
 
 
Sub AlarmMessage() 
  If Ie_locationName = IE.locationname And Ie_locationURL = IE.locationURL Then 
  '*** 情報が変わってない 
   ' IE のウインドウをアクティブにする 
   lngRet = SetForegroundWindow(IE.hWnd) 
   If lngRet <> 0 Then 
     ' アクティブにできたらキー送信して結果をコピー 
    SendKeys "^r", True   '*** 最新情報に更新 
    Ie_locationName = IE.locationname 
    Ie_locationURL = IE.locationURL 
   End If 
   
  Else 
   ' IE のウインドウをアクティブにする 
   lngRet = SetForegroundWindow(IE.hWnd) 
   If lngRet <> 0 Then 
    Ie_locationName = IE.locationname 
    Ie_locationURL = IE.locationURL 
 
   End If 
 
  End If 
   
  Application.OnTime Now + TimeValue("00:00:05"), "AlarmMessage" 
 
End Sub 
 
以上、参考までに・・・ 
 
 | 
     
    
   |