Access IE console and copy output through vba

XLSM Belgium

New Member
Joined
Mar 31, 2017
Messages
9
Hi,

I would need to access the console on an url in internet explorer.
I want to run the command
Code:
chart_data_d()
, and paste the output in my excel worksheet.

This is what I have so far: (console and copy output are missing)

Code:
Sub testing1()    Dim IE As Object
    
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://users.skynet.be/betberge/pvdiary/pvcalc.htm?date=20170615&long=3.3489&lat=50.8865&az=108&roof=42&peakw=4690&temp_coeff=-0.48&az2=0&roof2=0&peakw2=0&temp_coeff2=0"
        While IE.busy Or IE.readyState <> 4
            DoEvents
        Wend
        Application.Wait (Now() + TimeValue("0:0:01"))
    
    'Run the console command chart_data_d()
    'copy console output
    
    Sheets("terugverdientijd").Range("K14").Select
    ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
    
    IE.Quit
    Set IE = Nothing
    Range("A1").Select


End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I'm not sure if this does what you want because it returns much more data than is displayed in the console. Maybe the console output is truncated.

This code is the equivalent of navigating to the web page and then typing "javascript:chart_data_d();" without the quotes in the IE address bar.

Code:
Public Sub IE_Get_Data()
    
    Dim IE As Object
           
    ActiveSheet.Range("A1").ClearContents
           
    Set IE = CreateObject("InternetExplorer.Application")
    With IE
        .Visible = True
        .Navigate "http://users.skynet.be/betberge/pvdiary/pvcalc.htm?date=20170615&long=3.3489&lat=50.8865&az=108&roof=42&peakw=4690&temp_coeff=-0.48&az2=0&roof2=0&peakw2=0&temp_coeff2=0"
        While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
        
        .Navigate "javascript:chart_data_d();"
        While .Busy: DoEvents: Wend
        Do
            DoEvents
        Loop Until InStr(1, .Document.body.innertext, "{""title"":{""") = 1
        
        ActiveSheet.Range("A1").Value = .Document.body.innertext
        '.Quit 'close IE tab/window
    End With
            
    Set IE = Nothing
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top