Avatar of jimseiwert
jimseiwert
Flag 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
.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
jimseiwert

8/22/2022 - Mon
Bob Learned

What "browser" are you referring to?  What .NET version are you working with?
Praveen Venu

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);
   
Nasir Razzaq

Or if it is a HTML file as you mentioned

Dim fileContent as String = IO.File.ReadAllText(filepath)
Clipboard.SetText(fileContent, TextDataFormat.Text)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
jimseiwert

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jimseiwert

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