VBA WebBrowser Control - Search for String

Dave Punky

Board Regular
Joined
Jan 7, 2010
Messages
133
Hi all,

I'm trying to use the Microsoft Web Browser additional control on a userform within Excel VBA but I'm having problems trying to find a string within the document.

Basically I have the page loaded within the web control, but what I want to do is search for a string and the 5 characters directly after it (and put this in a text box). Basically if I'm looking for the string "Number:" then I want that string returned and the 5 characters afterwards so it would read "Number: 1234" in my ajacent textbox once retrieved. Esentially it's searching the document on a page like Ctrl + F on a regular page, it's just getting the next few characters afterwards and making this a string.

I found a really useful guide (http://www.vbforums.com/showthread.php?t=384076) which explains the basics of searching strings and using the WebBrowser control generally but I'm having problems manipulating this to do what I want. Basically I can find the string and confirm it is on the document, but I can't actually pull the string out of the webpage/control. I know if this was just an Excel document it would be super easy using Left() or Mid() but I've not had much luck when doing this using said control.

Is there anyone out there who may be able to help?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I'm happy to take a look, but would really need to see the webpage or at least the source of the webpage :)
 
Upvote 0
Hello, maybe this can help:
Code:
Dim oCBrd As DataObject
Set oCBrd = New DataObject

SendKeys ("+{RIGHT 10}"), True
SendKeys ("^{INSERT}"), True

oCBrd.GetFromClipboard
sYuorVariable = oCBrd.GetText
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

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