|
-
Sep 13th, 2000, 01:42 AM
#1
Hi all,
I'm trying to set the content of the clipboard to be the words selected within the WebBrowser object. I've tried SendKeys "^C" but it didn't work. Anybody knows how to do this?
What I want to do is for user to highlight words within the WebBrowser object by drag-selecting with the mouse and then click a "Find" button. Therefore I need to capture the words which is highlighted by user which is supposed to be stored in the clipboard.
Is there any other way to do it besides SendKeys "^C" ?
If sendkeys is the only way to capture the highlighted words, what is the proper way to code it?
Any help is very appreciated.
Rgds,
David.
-
Sep 13th, 2000, 02:17 AM
#2
I had no problems using SendKeys. This is the code I used to try it out:
Code:
Private Sub Command1_Click()
WebBrowser1.SetFocus
SendKeys "^c", True
MsgBox Clipboard.GetText
End Sub
The important thing is to set focus to the WebBrowser control before using SendKeys.
Good luck!
-
Sep 13th, 2000, 02:33 AM
#3
Thanks a lot
I typed ^C instead of ^c, no wonder it didn't work..
thanks a lot for your help dude..
-
Sep 13th, 2000, 02:41 AM
#4
Actually it doesn't matter if you type ^c or ^C.
-
Sep 13th, 2000, 03:02 PM
#5
And to search in the Webbrowser:
Code:
Private Sub Command1_Click()
WebBrowser1.SetFocus
SendKeys "^f", True
SendKeys "SearchText", True
SendKeys "~", True
End Sub
-
Sep 13th, 2000, 06:36 PM
#6
Hyperactive Member
Please, don't use the SendKeys method. Remember, when you use the Webbrowser object, you have access to the Document object. If all you need to do is copy the highlighted text to the clipboard, just do the following:
Code:
Private Sub command1_click()
Dim rng As Object
Set rng = Webbrowser1.Document.selection.createRange()
Clipboard.SetText rng.Text
Set rng=Nothing
end sub
Hope this helps.
-
Sep 14th, 2000, 04:33 AM
#7
Originally posted by Matthew Gates
And to search in the Webbrowser:
Code:
Private Sub Command1_Click()
WebBrowser1.SetFocus
SendKeys "^f", True
SendKeys "SearchText", True
SendKeys "~", True
End Sub
Hmmm... yeah I posted that exact code in a previous post 
BTW reeset, do you have any documentation or help files on the web browser object, and in that case where can I get it.
-
Sep 14th, 2000, 01:37 PM
#8
That is the code you gave Joacim, sorry for not saying, "this code is from Joacim", wasn't even thinking about it.
Well, it's Joacim's code. Thanks Joacim, it'll come in handy to me as well .
Credit is given where it's needed.
-
Sep 14th, 2000, 06:36 PM
#9
Hyperactive Member
Joacim:
Actually, the selection and createText are objects associated with IE's Document Object. For information on that, just go to Microsoft and look through their knowledge base on the HTML objects available to IE. Whenever I program with the Webbrowser control, I generally try to think of it just as the parent object, and then interact with it accordingly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|