Hi all!
I have a problem that I have tried to figure out a long time now.
I need to get information from a website and paste it in the a2 cell on sheet3.
but I cant get it to work I have tried many different codes but I am stuck.
the code I have is:
Sub test2()
'klicka på en knapp utan namn
Dim IE As Object
Dim IEdoc As Object
Set IE = CreateObject("internetExplorer.Application")
With IE
.Visible = True
.navigate ("http://www.allabolag.se")
End With
While IE.readyState <> 4
Set xobj = objIe.document.getElementById("myDiv")
Set xobj = xobj.getElementsByClassName("myTable").Item(0)
Set xobj = xobj.getElementsByClassName("data")(0)
Debug.Print xobj.innerText
setxboj = Nothing
DoEvents
Wend
IE.document.getElementsByName("what").Item.innerText = ThisWorkbook.Sheets("blad2").Range("a2").Value
Set allInputs = IE.document.getElementsByTagName("input")
For Each element In allInputs
If element.getAttribute("src") = "/img/button_sok_56x25.png" Then
element.Click
Exit For
End If
Next element
'ID = Printtitel
Do While IE.Busy: DoEvents: Loop
Set sht = Sheets("Blad3")
RowCount = 1
sht.Range("a" & RowCount) = "Moderbolag:"
´missing code string
Set IE = Nothing
'ThisWorkbook.Sheets("blad3").Range("a2") = IE.document.getelementsbyid("Printtitel")
End Sub
The inner text that I trying to get is in the code:
HTML lang=SV XMLNS="Http://www.w3.org/199/xhtml
"< head >....< /head >"
"< body >"
then its 9 div strings
one table
then tbody in table
the second "< tr >"
in the "< td >" you have a "< h1 >" and ID is "printTitle"
and its the innertext of that Id I need!
im doing something wrong but I don't know what it is.
kind of new to extracting text from websites.
hope to find help here!
/ Robin
I have a problem that I have tried to figure out a long time now.
I need to get information from a website and paste it in the a2 cell on sheet3.
but I cant get it to work I have tried many different codes but I am stuck.
the code I have is:
Sub test2()
'klicka på en knapp utan namn
Dim IE As Object
Dim IEdoc As Object
Set IE = CreateObject("internetExplorer.Application")
With IE
.Visible = True
.navigate ("http://www.allabolag.se")
End With
While IE.readyState <> 4
Set xobj = objIe.document.getElementById("myDiv")
Set xobj = xobj.getElementsByClassName("myTable").Item(0)
Set xobj = xobj.getElementsByClassName("data")(0)
Debug.Print xobj.innerText
setxboj = Nothing
DoEvents
Wend
IE.document.getElementsByName("what").Item.innerText = ThisWorkbook.Sheets("blad2").Range("a2").Value
Set allInputs = IE.document.getElementsByTagName("input")
For Each element In allInputs
If element.getAttribute("src") = "/img/button_sok_56x25.png" Then
element.Click
Exit For
End If
Next element
'ID = Printtitel
Do While IE.Busy: DoEvents: Loop
Set sht = Sheets("Blad3")
RowCount = 1
sht.Range("a" & RowCount) = "Moderbolag:"
´missing code string
Set IE = Nothing
'ThisWorkbook.Sheets("blad3").Range("a2") = IE.document.getelementsbyid("Printtitel")
End Sub
The inner text that I trying to get is in the code:
HTML lang=SV XMLNS="Http://www.w3.org/199/xhtml
"< head >....< /head >"
"< body >"
then its 9 div strings
one table
then tbody in table
the second "< tr >"
in the "< td >" you have a "< h1 >" and ID is "printTitle"
and its the innertext of that Id I need!
im doing something wrong but I don't know what it is.
kind of new to extracting text from websites.
hope to find help here!
/ Robin