|
-
Jul 10th, 2007, 01:53 PM
#1
Thread Starter
Lively Member
Web Browser Control...
First, I have a web browser control that loads a webpage.
Once the webpage is loaded I then need to make a copy of that webpage and store it as a bitmap image in root drive c:\ of local machine.
Here's what I have so far... (Select, Copy, Clear selection)
But how do you create/save selection as image from clipboard ??
Is their a better way to do what I need ??
Code:
' Select all from webbrowser
WebBrowser1.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
' Copy the text to Clipboard
WebBrowser1.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER
' Clear the selection
WebBrowser1.ExecWB OLECMDID_CLEARSELECTION, OLECMDEXECOPT_DONTPROMPTUSER
-
Jul 10th, 2007, 01:58 PM
#2
Re: Web Browser Control...
Try this
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
Private Function SaveScreen(ByVal pstrFileName As String) As Boolean
'To get the Entire Screen
Call keybd_event(vbKeySnapshot, 1, 0, 0)
'To get the Active Window
'Call keybd_event(vbKeySnapshot, 0, 0, 0)
SavePicture Clipboard.GetData(vbCFBitmap), pstrFileName
SaveScreen = True
End Function
Private Sub Command1_Click()
Call SaveScreen("C:\Windows\Desktop\shot1.bmp")
End Sub
-
Jul 10th, 2007, 02:30 PM
#3
Thread Starter
Lively Member
Re: Web Browser Control...
Hack...
First off, thanks for your helpful code and quick reply !!!
I have tried out you code and it works great... However I really need to be able to capture only what is contained within the web browser control and not the entire form.
Thanks Again !!!
-
Jul 10th, 2007, 02:34 PM
#4
Re: Web Browser Control...
If you notice that the code I posted gives you two options.
Entire Screen is active.
Comment that out, and use the other one which is just the Active Window. See how that works.
-
Jul 10th, 2007, 02:45 PM
#5
Thread Starter
Lively Member
Re: Web Browser Control...
Hack,
I must be doing something wrong because it gives me the same image as before (the entire screen).
I first thought maybe I needed to "setfocus" to the web browser control before calling your routine but that was no help...
Code:
WebBrowser1.SetFocus
Call SaveScreen("C:\" & Format(Now, "HHMMSS") & ".bmp")
Clipboard.Clear ' <-- doesn't seem to clear clipboard ??
-
Jul 10th, 2007, 02:47 PM
#6
Re: Web Browser Control...
Arey you using Call keybd_event(vbKeySnapshot, 0, 0, 0) instead of Call keybd_event(vbKeySnapshot, 1, 0, 0)
-
Jul 10th, 2007, 02:53 PM
#7
Thread Starter
Lively Member
Re: Web Browser Control...
Yup... Calling the correct line.
Call keybd_event(vbKeySnapshot, 0, 0, 0)
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
|