Hello,
I cannot import data from teh following site:
then link "SEMANAL - RESUMO I"
Select option button ESTADOS, combo box GASOLINA
Submmit - Processar
The resultant table, starting with word "ESTADO" in light blue, has spanned cells (in the header), I think Web queries of Excel cannot import tables like that, is that right? If not how can I import.
Is there any other way to import the table data? I am looking for a solution in VBA.
I manage to go to the final site with the following code, but I do not know how to import.
Thanks in advance,
Carlos
CODE (first of all I checked References - Microsoft HTML Object Library and Microsoft Internet Controls).
Please put a breakpoint at line 47 to see the web page loaded:
Option Explicit
Sub ImportWithIE()
Dim IEApp As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim URL As String
Dim Formulario As HTMLFormElement
Dim RadRegiao As Object
Dim RadINP As HTMLInputElement
Dim SelCombustivel As HTMLSelectElement
Dim BtnSubmit As HTMLButtonElement
URL = "
Set IEApp = New InternetExplorer
IEApp.Visible = True
IEApp.Navigate URL
Do
DoEvents
Loop Until IEApp.ReadyState = 4
Set HTMLDoc = IEApp.Document
IEApp.Navigate HTMLDoc.Links(2)
Do
DoEvents
Loop Until IEApp.ReadyState = 4 And Not IEApp.Busy
Set Formulario = HTMLDoc.forms("frmAberto")
Set RadRegiao = Formulario.elements("RdResumo")
Set RadINP = RadRegiao.Item(2)
RadINP.Click
Set SelCombustivel = Formulario.elements("selcombustivel")
SelCombustivel.Value = "487*Gasolina"
'(Submmit)
Set BtnSubmit = Formulario.elements("image1")
BtnSubmit.Click
Do
DoEvents
Loop Until IEApp.ReadyState = 4 And Not IEApp.Busy
'NEED to import here
Sheets("Data").Select
Set HTMLDoc = IEApp.Document
Set Formulario = HTMLDoc.forms("frmAberto")
Set HTMLDoc = Formulario.Document
' ????????????
IEApp.Quit
Set IEApp = Nothing
End Sub
Carlos César tanaka
Curso de Excel / Access
MPR Informática
I cannot import data from teh following site:
then link "SEMANAL - RESUMO I"
Select option button ESTADOS, combo box GASOLINA
Submmit - Processar
The resultant table, starting with word "ESTADO" in light blue, has spanned cells (in the header), I think Web queries of Excel cannot import tables like that, is that right? If not how can I import.
Is there any other way to import the table data? I am looking for a solution in VBA.
I manage to go to the final site with the following code, but I do not know how to import.
Thanks in advance,
Carlos
CODE (first of all I checked References - Microsoft HTML Object Library and Microsoft Internet Controls).
Please put a breakpoint at line 47 to see the web page loaded:
Option Explicit
Sub ImportWithIE()
Dim IEApp As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim URL As String
Dim Formulario As HTMLFormElement
Dim RadRegiao As Object
Dim RadINP As HTMLInputElement
Dim SelCombustivel As HTMLSelectElement
Dim BtnSubmit As HTMLButtonElement
URL = "
Set IEApp = New InternetExplorer
IEApp.Visible = True
IEApp.Navigate URL
Do
DoEvents
Loop Until IEApp.ReadyState = 4
Set HTMLDoc = IEApp.Document
IEApp.Navigate HTMLDoc.Links(2)
Do
DoEvents
Loop Until IEApp.ReadyState = 4 And Not IEApp.Busy
Set Formulario = HTMLDoc.forms("frmAberto")
Set RadRegiao = Formulario.elements("RdResumo")
Set RadINP = RadRegiao.Item(2)
RadINP.Click
Set SelCombustivel = Formulario.elements("selcombustivel")
SelCombustivel.Value = "487*Gasolina"
'(Submmit)
Set BtnSubmit = Formulario.elements("image1")
BtnSubmit.Click
Do
DoEvents
Loop Until IEApp.ReadyState = 4 And Not IEApp.Busy
'NEED to import here
Sheets("Data").Select
Set HTMLDoc = IEApp.Document
Set Formulario = HTMLDoc.forms("frmAberto")
Set HTMLDoc = Formulario.Document
' ????????????
IEApp.Quit
Set IEApp = Nothing
End Sub
Carlos César tanaka
Curso de Excel / Access
MPR Informática