VBA Sendkeys to an Excel Embeded Browser (Micorsoft WebBrowser Control)

Naed1

New Member
Joined
Nov 15, 2013
Messages
26
Hi I have an Embedded Active X Browser (Microsoft WebBrowser Control). Named "Browser1" On Sheet1 of my workbook.

It is working well and I can pull up web pages using it. If in a Macro in Sheet1 I place the command Browser1.Visible = False it hides the Browser. Browser1.Visible = True will then make it visible again.

Once I load a web page in I want to Activate the Browser Window and Select and Copy the text data in the window by using SendKeys (^a^c).

To test this, I have an Active X Button who's macro get placed on Sheet1 when I click on the button while in Design Mode.

I can't seem to find a way of sending the SendKeys command

My Code is

Private Sub SelectAllBrowser_Click()
WebBrowser1.Activate
SendKeys ("^a^c")
End Sub

- When I press my "SelectAllBrowserl" button nothing happens
- I get the same results if I replace SendKeys with Application.SendKeys.
- If I try WebBrowser1.SendKeys I get the Error Message "Object Does Not support this property or method". Application.WebBrowser1.SendKeys gives the same Error Message.
- If I manualy click on the Browser and then press the ^a^c keys it does select and copy all the data.
- I have tried selecting the Browser with the command Browser1.Select and it does select the Browser but differently (it puts small empty circles at the corners of the browser) than if I just manually click on the Embedded Browser, which does not show any visible signs of being selected, but it is. Using the SendKeys in different forms after the Browser1.Select command does not do anything either.
- I believe if I Activate IE and then send the command Application.SendKeys(^a^c) it does SELECT ALL and Then COPY the data on the IE Browser onto the clipboard. Presently I do this with Firfox and it works well. I would like to do this however on the Browser I have Embedded on the worksheet using the Active X "Microsoft WebBrowser" control .
- Any Suggestions on how to SELECT ALL and COPY the Embedded Browser Data to the Clipboard, or Another way of getting the data from the Browser. I only need the Text Data, which I then parse after I Paste Special (text) to another worksheet.
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi Again,

For Any one interested, after playing around with WebBrowser1 more, I found a workaround. See below for a description. It is a bit of a kludge and I would rather have the Browser directly Embedded on a worksheet instead of on a Mode-less Form.

If any one knows how I can set focus to the Browser when it is imbedded in the worksheet so that I can then use the SendKeys "^a^c" Command to SELECT ALL and COPY the data in th Browser I would greatly appecate a response.

If I Embedded the Browser in a Form(mode-less for me) then I can use the following Macro Commands to SELECT ALL the Browers Data and COPY it to the Clipboard.

Code:
WebBrowser1.SetFocus
SendKeys "^a^c"

<style type="text/css"><!-- .nav-sprite-v1 .nav-sprite { background-image: url(http://g-ecx.images-amazon.com/images/G/01/gno/sprites/global-sprite-32-v1._V349056651_.png); background-position: 0 1000px; background-repeat: repeat-x; } .nav-spinner { background-image: url(http://g-ecx.images-amazon.com/images/G/01/javascripts/lib/popover/images/snake._V192571611_.gif); } .nav-ajax-loading .nav-ajax-message { background: center center url(http://g-ecx.images-amazon.com/images/G/01/javascripts/lib/popover/images/snake._V192571611_.gif) no-repeat; } .iss-sprite { background-image: url(http://g-ecx.images-amazon.com/images/G/01/nav2/images/gui/beacon-sprite._V391206562_.png); } --></style> The Setfocus command does not work if the WebBrowser1 is inbedded in a worksheet instead of in a Form.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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