Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB6: Copying the entire contents of the webpage to the clipboard
#3
(2022-10-04, 08:49:50)wila Wrote: Hi Przemek,

Do you want the Html or the Text?

If you only want the text then you could use javascript along the lines of:
Code:
  Dim jScript As String   Dim varParams(0) As Variant     jScript = "() => {" & vbCrLf   jScript = jScript & "document.body.textContent;" & vbCrLf   jScript = jScript & "}" & vbCrLf   Document.BrowserDispatch EdgeWebBrowser.IDispatchPointer   Document.RunAnonymousFunction 2, varParams, jScript

Then on the raised event retrieve decode the json object to remove the url encoding.
Code:
Private Sub Document_OnRunAnonymousFunction(ByVal Id As Long, ByVal Params As Variant, ByVal Data As String, ByVal Error As Long)   Dim sData as String   If Id = 2 Then     sText = Document.DecodeJsonObjectString(Data)   ElseIf Id = 3 Then

I think that should be it.

Once you have the text you can add it to the clipboard in the host application.
There's no need to do that from within the browser control as the clipboard is global to the Windows session.

If you have a bit I can add the above as a function to the document control similar to the currentHtml one to make it a bit easier to use.

--
Wil

Thank you for the tip. I will check it soon.
 
On the other hand, my intention was to copy the whole content
I mean both text and images at one time.

However, adding the CurrentText method seems like a good idea for copying text.
It would be great if you could add such a method in the near future

--
Przemek
Reply


Messages In This Thread
RE: VB6: Copying the entire contents of the webpage to the clipboard - by MrPrzemek - 2022-10-04, 13:55:47

Forum Jump:


Users browsing this thread: 1 Guest(s)