编译错误参数不是可选的

我有一个代码,我跑在一个临时的计算机上,运行完美,但似乎我不能让它在这台机器上运行,即使我参考作者build议

我明白了

编译错误参数不是可选的

Sub kl()

 Sub kl() Dim ie As InternetExplorer Dim htlm As HTMLDocument Dim link As Object Dim links As Object Dim erow As Long Application.ScreenUpdating = False Set ie = New InternetExplorer ie.Visible = False ie.navigate = "http://www.google.com" Do While ie.ReadyState <> READYSTATE_COMPLETE Application.StatusBar = "loading website" DoEvents Loop Set Html = ie.document Set links = Html.getElementsByTagName("a") For Each link In links erow = Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row Cells(erow, 1).Value = link Cells(erow, 1).Columns.AutoFit Next Set.ie = Nothing Application.StatusBar = "" Application.screenupdate = True End Sub 

任何帮助,为什么它导致错误? 我参考了MSXML,ActiveX库,MSHTML和MS Internet控制

我得到ie.navigate =“ http://www.google.com ”的错误

工作代码:

 Sub kl() Dim ie As Object Dim htlm As HTMLDocument Dim link As Object Dim links As Object Dim erow As Long Set ie = CreateObject("InternetExplorer.Application") ie.Visible = False ie.navigate "http://www.google.com" Do While ie.ReadyState <> READYSTATE_COMPLETE Application.StatusBar = "loading website" DoEvents Loop Set HTML = ie.document Set links = HTML.getElementsByTagName("a") For Each link In links erow = Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row Cells(erow, 1).Value = link Cells(erow, 1).Columns.AutoFit Next Set ie = Nothing Application.StatusBar = "" End Sub 

我相信错误在于你如何创build和调用Internet Explorer应用程序。

试试这个:

 ... Set ie = CreateObject("InternetExplorer.Application") ie.Visible = False ie.navigate "http://www.google.com" ' This seems to be the main thing, don't use `=` ...