How to copy WebBrowser Content to Clipboard as Text

 

In order to copy the content of the WebBrowser control to the clipboard as Text  you need to dive into the underlying COM interfaces inside the webbrowser control.  IHTMLDocument2 gives us the selection.  We just need to pull the text out of it:

 

IHTMLDocument2^ htmlDocument = (IHTMLDocument2^) webBrowser1->Document->DomDocument;

IHTMLSelectionObject^ mySelection = htmlDocument->selection;

String^ text = ((IHTMLTxtRange^ )mySelection->createRange())->text;

Clipboard::SetText(text);