Select and Copy all from Chrome webpage opened by VBA code in Excel

BigShango

Board Regular
Joined
May 8, 2014
Messages
106
Hi,

I have a task that involves opening links in Chrome then copying and pasting the entire page into Excel (I won't bore you with what happens then, it's this particular part I'm struggling to automate).

I've managed to get Excel to open hyperlinks easy enough (so in simple terms I'll have a list of hyperlinks that it'll go down one by one and open up) but after that I'm stuck. All I'm needing it to do is replace a human going CTRL+A and then CTRL+C on the webpage that has opened up (everything after that works fine), but I can't figure out how. I've even tried just doing SendKeys but that doesn't seem to work. Here's the relevant part of my current code:

VBA Code:
            mycell.Hyperlinks(1).Follow NewWindow:=False
            Application.Wait (Now() + TimeValue("00:00:05"))
            SendKeys "^{A}"
            SendKeys "^{C}"

It opens the hyperlink, waits a few seconds and then in theory it should select all then copy the webpage I'm now looking at - but it neither selects all nor copies anything to the clipboard. Is there something I'm doing wrong there, or a better way to do this? I can't install anything extra on the machines that'll be doing this.

Any help would be greatly appreciated.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I've realised I was using SendKeys slightly wrong - I've now changed it to:

VBA Code:
SendKeys "^a"
SendKeys "^c"

which does "send the keys" but appears to do so on my VBA editor rather than the Chrome window that opened
 
Upvote 0
I've solved my own problem - always the way that after giving up and coming here I think of something else lol. In case anyone else comes across the same issue.

VBA Code:
            mycell.Hyperlinks(1).Follow NewWindow:=False
            Application.Wait (Now() + TimeValue("00:00:05"))
            AppActivate ("Name of webpage - Google Chrome")
            SendKeys ("^a")
            SendKeys ("^c")

I'm not sure how you'd do it if you don't know the title of the page you're opening in Chrome but fortunately for me they'll always have the same title.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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