[vb6.0/vba] 인터넷익스플로워 띄우기 및 검색하기/FindIE > vb6.0/vba

본문 바로가기

vb6.0/vba

[vb6.0/vba] [vb6.0/vba] 인터넷익스플로워 띄우기 및 검색하기/FindIE

회원사진
하나를하더라도최선을
2020-03-16 21:52 4,810 0

본문



단순히 인터넷 익스플로워를 띄우는 방법
CreateObject("WScript.Shell").Run "http://naver.com"1
 
 
 
 
아래는 열려있는 창이 있으면 열려있는 익스플로워의 첫번째 창을 이용해서 
네이버 검색을 하는 예제입니다.
 
 
naver.com에서 "네이버"를 검색해서 관련 연관검색어를 메세지 박스로 띄워줍니다.
 
 
Dim IE As Object
 
Sub 버튼()
    If IE Is Nothing Then Set IE = FindIE
    On Error Resume Next
    With IE
        .Visible = True
        .Navigate2 "naver.com"
        If Err Then Set IE = Nothing: 버튼: Exit Sub
        Do While .Busy = True Or .ReadyState <> 4
            DoEvents
        Loop
        .Document.all("query").Value = "네이버"
        .Document.all("search_btn").Click
        Do While .Busy = True Or .ReadyState <> 4
            DoEvents
        Loop
        MsgBox .Document.all("nx_related_keywords").innerTEXT
    End With
End Sub
 
Function FindIE() As Object
    Dim obj As Object, Count&, URL$, Title$, x&
    Set obj = CreateObject("Shell.Application")
    On Error Resume Next
    Count = obj.Windows.Count
    For x = 0 To (Count - 1)
        URL = obj.Windows(x).Document.Location
        Title = obj.Windows(x).Document.Title
        If TypeName(obj.Windows(x).Document) = "HTMLDocument" Then
            Set FindIE = obj.Windows(x)
            Exit For
        End If
    Next
    If FindIE Is Nothing Then Set FindIE = CreateObject("InternetExplorer.Application")
End Function
 
 
 
 
 

댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색