views:

151

answers:

2

I need to retrieve only selected portion of a webpage (user open a webpage in web-browser control, then he/she would select some portion of a webpage, i just need only those selected portion/text) in vb.net in visual basic language. How to do ?

i am using microsoft visual studio 2008
Language: Visual Basic
FrameWork: vb.net 3.5

A: 

Perhaps here are some answers for you(first post attachment):

Manipulate/Change/Form Fill data in webpages using the Webbrowser control

Tim Schmelter
@Tim: could you distill one of the answers on that page and include it in your answer?
John Saunders
@John: I must admit that im not familiar with the webbrowser control but it seems that in the link is added an attachment where some examples are provides for his requirement.
Tim Schmelter
@Tim: so, you found the link and posted it, but you don't understand what's at the link, so we've just got to go read it. Not the best way to answer questions on SO.
John Saunders
@John: I've looked at the provided example code and thought that this could be exactly what user128647 was looking for. But without more background information from him and more knowledge of the underlying com objects and the functionality of webbrowser controls, i found it difficult to encapsulate the most helpful parts. So its better to provide a link that might help than do nothing or make comments that do not help(use javascript etc.).
Tim Schmelter
A: 

In terms of IE's API, you can get the select text by getting the selection object via IHTMLDocument2::Selection the property, then create a range object via IHTMLSelectionObject::createRange. If the return range's type property is "Text", you can then query IHTMLTxtRange from it and get the selected text via IHTMLTxtRange::text.

It is unclear which webbrowser control you are referring to. There are 3 webbrowser controls in the .Net Framework, one in Windows Forms, one in WPF, and one in Silverlight. Anyway, you can call InvokeScript or use the unmanaged interface like csexwb's GetSelectedText, if one of the method is supported by your control library.

Next time mention which control library you are using when you ask the question. Merely mentioning the language you choose isn't enough to resolve the ambiguity in class names.

Sheng Jiang 蒋晟