I have a HTMLViewer with some contents in it.
If I right click on the HTMLViewer and Select All and copy its contents I can CTRL-V (paste) in any place.
Not a text, but a real web page (I am using Windows).
I’d like to know if I can do this by code and how.
Thanks for any help.
I did this as two extension methods just to make it a bit more apparent what’s happening. These could be combined in to a SelectAllAndCopy method, though.
In a module, add the following methods:
Public Sub SelectAll(extends h as DesktopHTMLViewer)
var exec() as string
exec.Add( "var selection = window.getSelection()," )
exec.Add( " range = document.createRange();" )
exec.Add( "range.selectNodeContents(document.body);" )
exec.Add( "selection.removeAllRanges();" )
exec.Add( "selection.addRange(range);" )
Public Sub Copy(extends h as DesktopHTMLViewer)
Thank you Anthony.
It looks promising.
I’ll do it as you show and I will tell you the results.
It works great! Thanks!
Now I will try to develop it with the Clipboard API and I will tell you how it goes.