Link to home
Start Free TrialLog in
Avatar of jimseiwert
jimseiwertFlag for United States of America

asked on

VB.NET Copy WebPage To Clipboard

I am trying to take html string and paste it into word, I have the code to work to paste html from the clipboard to word as paste special but how would I go about copying an html file to the clipboard.

In the browser I would do select all and copy and paste in word.

Thanks for your help in advance
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What "browser" are you referring to?  What .NET version are you working with?
Get the pages source using the HttpWebRequest class

Then copy it to clipboard as HTML format using the below code

 Clipboard.SetText(MyHtmlText, TextDataFormat.Html);
Or if it is a HTML file as you mentioned

Dim fileContent as String = IO.File.ReadAllText(filepath)
Clipboard.SetText(fileContent, TextDataFormat.Text)
Avatar of jimseiwert
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jimseiwert


Also in word then I do  a paste special in code to paste it as html