Copy IE window contents to excel

sidsmot

Board Regular
Joined
Apr 11, 2002
Messages
50
Hi,
is there a way to copy the contents of a ie window opened by the code below? This is additional code to a webquery - to be used when navigation thro' the website is required

Sub Test()
Const url As String = ' ****** the address is obtained from another macro
Dim ie As Object
Dim document As Object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.navigate url
Do While .ReadyState <> 4: Loop
 
Don't know how it works but on this board there is an 'Export to Microsoft Excel' option available via the right-click menu -
PM JPG
for some info
 
Upvote 0
Actually, that's not a "feature" of the board, but from IE when handling tables... I guess MS is making it easier to use its own set of products !
 
Upvote 0
But... since you got me interested, this selects everything in the window and copies it (I pasted it in the Active sheet to test too)

<font face=Courier New>
<SPAN style="color:#00007F">Sub</SPAN> Test()
    <SPAN style="color:#00007F">Const</SPAN> url <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "www.mrexcel.com/board2" <SPAN style="color:#007F00">' ****** the address is obtained from another macro</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> ie <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
    <SPAN style="color:#007F00">'Dim document As Object</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> ie = CreateObject("internetexplorer.application")
    <SPAN style="color:#00007F">With</SPAN> ie
        .Visible = <SPAN style="color:#00007F">True</SPAN>
        .Navigate url
        <SPAN style="color:#00007F">Do</SPAN> <SPAN style="color:#00007F">While</SPAN> .ReadyState <> 4
            DoEvents
        <SPAN style="color:#00007F">Loop</SPAN>
        .ExecWB 17, 2
        .ExecWB 12, 2
        ActiveSheet.Paste Range("A1")
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
 
Upvote 0
Juan Pablo González said:
Actually, that's not a "feature" of the board, but from IE when handling tables... I guess MS is making it easier to use its own set of products !

Evidently I spend too much time lurking on this board and hadn't noticed this as an IE feature! :lol:
 
Upvote 0
I just used you code for copying the contents of a webpage to a worksheet.

Is there a way to control which parts of the page are copied and pasted.

Example:
I have a site that is nothing more than a list of availible files.
here are the files:

060904-Ford_LossesAndDelinquency.xls
061004NashvilleRollBack.snp
061004_NSC_LD_Agent_RPC.snp
061004_NSC_LD_Agent_XHINOCON.snp
061004_NSC_LD_Agent_XLOC00_44.snp
061004_NSC_LD_Agent_XU45.snp
061004_NSC_LD_Agent_XU45BDNM.snp
061004_NSC_LD_Agent_XU45BZNA.snp
061004_NSC_LD_Agent_XU45MA.snp
061004_NSC_LD_Agent_XU45NOCOD.snp
06102004Ford-EARLYDFLT-0to4PmtMade.xls
061104RN1STPDLR.prn
061104_Ford-DAR.xls
AM_StatsJan_March2004.xls
April2004-Ford_LossesAndDelinquency.xls
April2004BadNumberDailyQCount.xls
April2004BadNumberPenetration.xls
April2004LPPenetration.xls
April2004LPPenetration.zip
April2004NoContactDailyQCount.xls
April2004NoContactPenetration.xls
April2004_DAR.pdf
Daily Snapshot JT LR April 2004.xls
Ford-BRAN6089.xls
Ford-BRANGT90.xls
Ford_Delinquent_Loss_Report2004.xls
Jan_March2004-AlphaEmployeeList.pdf
Jan_March2004-ComTeamEmployeeList.pdf
Jan_to_March2004_LP_Ranking-Ford.pdf
MTD-060604AlphaEmployeeList.pdf
MTD-060604COMTeamEmpList.pdf
May2004-AlphaEmployeeList.pdf
May2004-ComTeamEmployeeList.pdf
May2004-Ford_LossesAndDelinquency.xls
May2004_AM_Ranking-Ford.pdf
May2004_LPPenetration.zip
May2004_LP_Ranking-Ford.pdf
NSC Management Contact List June 04.xls
NSC_Campus_OrgChart_May04.xls


Close this Window


All I need from this list is anything with the following name regarless of the date on the front.

060904-Ford_LossesAndDelinquency.xls

The date "060904" will change, sometimes there are 2 files and they change positions in the list. i.e. it's not always the first one.

I also need to have the macro open the most recent date in the current excel window.

Any help here?
 
Upvote 0

Forum statistics

Threads
1,226,837
Messages
6,193,257
Members
453,786
Latest member
ALMALV

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