Hi Friends,
Trying to extract table data from multiple urls at once with Excel VBA.
Here are sample urls trying to extract from
ColumnA
[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]https://www.abbreviations.com/acronyms/NETWORKING/149[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/150[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/151[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/152[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/153
I want to extract abbreviation and full form into excel.
[/TD]
[/TR]
</tbody>[/TABLE]
Here is the code which is not working
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Option Explicit
Public Sub GetTable()
Dim sResponse As String, html As HTMLDocument, clipboard As Object
Set html = New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://disclosure.bursamalaysia.com/FileAccess/viewHtml?e=2891609", False
.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
.send
sResponse = StrConv(.responseBody, vbUnicode)
End With
html.body.innerHTML = sResponse
With html
ThisWorkbook.Worksheets("Sheet1").Cells(1, 1) = .querySelector(".company_name").innerText
Set clipboard = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
clipboard.SetText .querySelector(".InputTable2").outerHTML
clipboard.PutInClipboard
End With
ThisWorkbook.Worksheets("Sheet1").Cells(2, 1).PasteSpecial
End Sub
</code>
Trying to extract table data from multiple urls at once with Excel VBA.
Here are sample urls trying to extract from
ColumnA
[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]https://www.abbreviations.com/acronyms/NETWORKING/149[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/150[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/151[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/152[/TD]
[/TR]
[TR]
[TD]https://www.abbreviations.com/acronyms/NETWORKING/153
I want to extract abbreviation and full form into excel.
[/TD]
[/TR]
</tbody>[/TABLE]
Here is the code which is not working
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Option Explicit
Public Sub GetTable()
Dim sResponse As String, html As HTMLDocument, clipboard As Object
Set html = New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://disclosure.bursamalaysia.com/FileAccess/viewHtml?e=2891609", False
.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
.send
sResponse = StrConv(.responseBody, vbUnicode)
End With
html.body.innerHTML = sResponse
With html
ThisWorkbook.Worksheets("Sheet1").Cells(1, 1) = .querySelector(".company_name").innerText
Set clipboard = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
clipboard.SetText .querySelector(".InputTable2").outerHTML
clipboard.PutInClipboard
End With
ThisWorkbook.Worksheets("Sheet1").Cells(2, 1).PasteSpecial
End Sub
</code>
Last edited: