2013-05-29 2 views
0

WebBrowser 컨트롤을 사용하고 있지 않습니다. IE를 제어하기 위해 변수의 IE 프로세스를 가져 오려고합니다.자동 스크롤 Internet Explorer

내 목표는 필요한 경우 자동으로 페이지를 아래로 스크롤하는 것입니다. 여기에 내 코드로 IE를 시작하는 방법에 대한 자세한 정보는 :

나 ... 나는 페이지를 아래로 스크롤 할 수 있도록 할 수있는 방법이 있나요하지만 IE를 제어 할 수 없습니다
Dim IE As SHDocVw.InternetExplorer 

    IE = CreateObject("InternetExplorer.Application") 
    IE.Visible = True 
    IE.Navigate("C:\rptStatusProd.xml") 'load web page google.com 

    While IE.Busy 
     Application.DoEvents() 'wait until IE is done loading page. 
    End While 

    IE.FullScreen = True 

? 웹 페이지가 회사 TV 전체에 걸쳐 표시 될 것이고 웹 페이지에 너무 많은 데이터가있는 경우 페이지를 스크롤해야 볼 수 있기 때문에 페이지를 자동으로 위/아래로 스크롤하고 싶습니다.

답변

2

귀엽지는 않지만 ... 무언가입니다. 페이지 맨 위로 스크롤하여 맨 아래로 되돌아갑니다. 나는 웹 페이지에 그 사이에 표시 할 항목이 충분하지 않기 때문에 운이 좋다. 이 나를 위해 일했다 :

Imports mshtml 

Sub Main() 
    Dim IE As SHDocVw.InternetExplorer 

    IE = CreateObject("InternetExplorer.Application") 
    IE.Visible = True 
    IE.Navigate("C:\rptStatusProd.xml") 'load web page 

    While IE.Busy 
     Application.DoEvents() 'wait until IE is done loading page. 
    End While 

    IE.FullScreen = True 

    Dim doc As HTMLDocumentClass = IE.Document 
    Dim myProcesses() As Process 
    myProcesses = Process.GetProcessesByName("iexplore") 

    While myProcesses.Count > 0 
     Try 
      doc.activeElement.scrollIntoView(True) 'Scroll to top 
      System.Threading.Thread.Sleep(5000) 
      doc.activeElement.scrollIntoView(False) 'Scroll to bottom 
      System.Threading.Thread.Sleep(5000) 
     Catch COMEx As System.Runtime.InteropServices.COMException 
      'RPC Server unavailable, Internet explorer was closed 
     Catch ex As Exception 
      MsgBox(ex.Message) 
     End Try 
    End While 
End Sub