Reputation: 467
I am encountering an
Object doesn't support this property or method
Runtime error in excel vba.
Note : The code works fine in my laptop.This error happened when I migrated the code to my desktop pc.
Below is the UPDATED code.
Dim ie As InternetExplorer
Dim htmldoc As MSHTML.IHTMLDocument
Dim ro1 As MSHTML.IHTMLElementCollection
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = False
ie.navigate "url"
Set htmldoc = ie.document
Set ro1 = htmldoc.getElementById("table id").getElementsByTagName("tr")
ThisWorkbook.Sheets(1).Cells(k, j) = rows(k).Children(0).textContent
ro1(k).Children(0).textContent
is the error part.
I have checked Tools->References. Microsoft Internet Controls and Microsoft HTML Object Library has been checked.
Can anyone please guide me for this ?
Upvotes: 0
Views: 873
Reputation: 9976
Try using InnerText instead of textContent
and see if that works for you.
ThisWorkbook.Sheets(1).Cells(k, j) = rows(k).Children(0).InnerText
Upvotes: 1
Reputation: 21657
Start by adding a line Option Explicit
at the top of your module, and then Debug
->Compile
to identify variables and objects that aren't properly declared or are being misused, Keep compiling until no more warnings.
Also, don't use the word ROWS
as an object name. Rows
already means something in Excel & VBA.
Here is a list of reserved words that should be avoided. (I realize it's labelled Access 2007 but the list is very similar, and it's surprisingly difficult to find an recent 'official' list for Excel VBA.)
Upvotes: 0