Home Compile error Argument not optional
Reply: 0

Compile error Argument not optional

user1852
1#
user1852 Published in April 20, 2018, 10:50 am

I have a code I ran before on a temporary computer and ran perfectly but it seems I can't get it to run on this machine even if I reference suggested by the author

I get

Compile error Argument not optional

on 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

Any help on why it's causing error? Ive referenced MSXML, ActiveX Library, MSHTML and MS Internet Controls

I get error for ie.navigate = "http://www.google.com"

Working code :

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
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315404 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO