2014-02-18 70 views
1

我試圖通過ronVBA綁定修改

Sub test() 

Dim IE As Object 
Set IE = CreateObject("InternetExplorer.Application") 

my_url = "http://www.google.com" 

With IE 
    .Visible = True 
    .navigate my_url 
    .Top = 50 
    .Left = 530 
    .Height = 400 
    .Width = 400 

Do Until Not IE.Busy And IE.readyState = 4 
    DoEvents 
Loop 

End With 

' Find the desired url and click 
Set Results = IE.document.getElementsByTagName("a") 
For Each itm In Results 
    If itm.outerhtml = "B.A.C. VII" Then 
     itm.Click 

     Do Until Not IE.Busy And IE.readyState = 4 
      DoEvents 
     Loop 
     Exit For 
    End If 
Next 
End Sub 

修改上給我這個示例代碼現在我不是後期綁定的粉絲,所以我想從

修改前兩個語句
Dim IE As Object 
Set IE = CreateObject("InternetExplorer.Application") 

Dim IE As InternetExplorer.Application 
Set IE = New InternetExplorer.Application 

取代它們然而,這並不在我的代碼工作,即使我甲肝如下圖所示,Microsoft Internet ControlsMicrosoft HTML Object Library在引用上激活。

爲什麼這樣?

enter image description here

親愛mehow

我想到這一點,但它給了我的錯誤就看

enter image description here

回答

2
Dim ie As InternetExplorer 
Set ie = new InternetExplorer 

InternetExplorer是類名

enter image description here

+0

親愛@mehow我已經試過了,但讓我告訴你在我重新編輯的問題是什麼事 – ExoticBirdsMerchant

+1

@ExoticBirdsMerchant右所以'設置IE =新InternetExplorer' – 2014-02-18 12:28:54

+1

ohhhhhh得到了該死的,我必須打我的頭用的錘子什麼! – ExoticBirdsMerchant