-
Jul 12th, 2007, 02:26 PM
#41
Addicted Member
Re: Webbrowser Control Tip and Examples
When I click 'Open', it doesn't want to. It doesn't show any errors or anything, nothing happens.
VB Code:
Private Sub menuFileOpen_Click()
wWeb.ExecWB OLECMDID_OPEN, OLECMDEXECOPT_PROMPTUSER
End Sub
Can anyone help me?
-
Oct 1st, 2007, 01:23 PM
#42
New Member
Re: Webbrowser Control Tip and Examples
Hello,
I'm using this code from a previous example in thread.
Private Sub Command1_Click()
WebBrowser1.Document.All("q").focus
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.google.com/"
End Sub
It all works great. But due to the lack of documentatiion I can seem to find a way of entering something in the text box and then reloading the page. Any help would be greatly appreciated. Or even a link to some documentation would work too.
Thanks
-
Oct 1st, 2007, 04:38 PM
#43
New Member
Re: Webbrowser Control Tip and Examples
Figured it out. Just in case anyone is interested, this works.
Code:
WebBrowser1.Document.All("q").focus
WebBrowser1.Document.All("q").Value = "blah blah"
WebBrowser1.Document.All("btng").focus
WebBrowser1.Document.activeElement.Click
Cheers...
-
Oct 4th, 2007, 01:44 PM
#44
New Member
Re: Webbrowser Control Tip and Examples
i keep getting an Error 91 message. Anyone know why?
-
Oct 4th, 2007, 01:45 PM
#45
New Member
Re: Webbrowser Control Tip and Examples
The codes here dont seem to be working for me. I can get the page loaded using:
Code:
Private Sub Command0_Click()
Dim webBrowser1 As WebBrowser
Set webBrowser1 = New WebBrowser
Set webBrowser1 = CreateObject("InternetExplorer.Application")
With webBrowser1
.Navigate "http://www.ncl.com/edocs"
.Visible = True
.Document.Forms(0).all("txtResID").focus
.Document.Forms(0).all("txtResID").Value = "blah blah"
End With
End Sub
but nothing fills in and i get the error 91 message the .Document.Forms(0) line
-
Oct 4th, 2007, 01:50 PM
#46
New Member
Re: Webbrowser Control Tip and Examples
Code:
.Document.all("txtResID").focus
.Document.all("txtResID").Value = "blah blah"
Try making the following changes....
-
Oct 4th, 2007, 01:53 PM
#47
New Member
Re: Webbrowser Control Tip and Examples
now i get an error that says "Runtime error -2147467259 (80004005) Autmation Error Unspecified Error)
-
Oct 4th, 2007, 01:58 PM
#48
New Member
Re: Webbrowser Control Tip and Examples
Code:
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.ncl.com/edocs"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
With WebBrowser1
.Document.Forms(0).All("txtResID").focus
.Document.Forms(0).All("txtResID").Value = "blah blah"
End With
End Sub
This won't load IE but use the webbrowser control in the form.
-
Oct 4th, 2007, 02:05 PM
#49
New Member
Re: Webbrowser Control Tip and Examples
That code tells me WebBrowser1 is not defined. Don't i need to dim it somewhere?
bwt - im using VB through MS Access.
-
Oct 4th, 2007, 02:10 PM
#50
New Member
Re: Webbrowser Control Tip and Examples
Ahhhh..Ok. Let me think about this because my code works fine in VB. I tested it.
Do you have access to the "microsoft internet control", ieframe.dll? If so, just add it to your project and that will be the end of it.
-
Oct 4th, 2007, 02:11 PM
#51
New Member
Re: Webbrowser Control Tip and Examples
-
Oct 4th, 2007, 02:15 PM
#52
New Member
Re: Webbrowser Control Tip and Examples
im using the microsoft internet control library, but its called "shdocvw.dll". What is "ieframe.dll"?
-
Oct 4th, 2007, 02:16 PM
#53
New Member
Re: Webbrowser Control Tip and Examples
Let me try a few things in Access..
-
Oct 4th, 2007, 02:22 PM
#54
New Member
Re: Webbrowser Control Tip and Examples
Sorry about the ieframe thing. You're right, it's shdocvw.dll.
-
Oct 4th, 2007, 02:23 PM
#55
New Member
Re: Webbrowser Control Tip and Examples
thank you for helping me out with this. I've been going nuts for the past week trying to get this to work!
In Access i have a button that launchs this code OnClick (if that helps any).
-
Oct 4th, 2007, 02:34 PM
#56
New Member
Re: Webbrowser Control Tip and Examples
Well..I'm new to Access 2007 (sometimes hard to figure where things are in a new version) and I don't see the internet control component and I've tried a few things but I can't seem to add it. So I have no way of helping you in Access.
My guess as to what your problem is that you're trying to access the text box before the page is fully loaded. Add the navigate command to the form_load part (get rid of it from the button click event). Once the page is fully loaded, click your button. Hope this helps.
-
Oct 4th, 2007, 02:38 PM
#57
New Member
Re: Webbrowser Control Tip and Examples
in the VB editor: Tools > References > Microsoft Internet Controls.
i tried adding:
Code:
Do Until webBrowser1.Busy = False
Do Events
Loop
to make sure the page was fully loaded, but that doesnt work either.
-
Oct 4th, 2007, 02:43 PM
#58
New Member
Re: Webbrowser Control Tip and Examples
I got that far but I can't actually add the component to the form. Were you able to actually add the component to your form? Are you using Access 2007?
-
Oct 4th, 2007, 02:45 PM
#59
New Member
Re: Webbrowser Control Tip and Examples
im using Access 2003. To add it to the form, you just make sure the box next to it is checked, yes?
-
Oct 4th, 2007, 02:53 PM
#60
New Member
Re: Webbrowser Control Tip and Examples
i definitely think my problem is that its not waiting for the browser to stop loading.
if i add an If webBrowser1.Busy = False statement around my .document lines, i get no error, but at the same time it doesnt fill in the fields.
-
Oct 4th, 2007, 02:55 PM
#61
New Member
Re: Webbrowser Control Tip and Examples
If I were using 2003 I wouldn't have any problems. Welcome to the World of 2007. If I figure it out I will post back..
-
Oct 4th, 2007, 03:06 PM
#62
New Member
Re: Webbrowser Control Tip and Examples
ok thats definitely my problem. I found a sub ruitine that Pauses for given amount of time, so i made it pause for 10 seconds, and it works!
Except, thats not a very reliable way of doing it in case the page takes a longer time to load for some reason.
how can i just have it check that the page is done and completely loaded?
-
Oct 4th, 2007, 03:08 PM
#63
New Member
Re: Webbrowser Control Tip and Examples
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Code:
With WebBrowser1
.Document.Forms(0).All("txtResID").focus
.Document.Forms(0).All("txtResID").Value = "blah blah"
End With
End Sub
FYI. My toolbox in Access is greyed out and I can't get to it..Seems like there's lots of others in my situation out there...
-
Oct 4th, 2007, 04:21 PM
#64
New Member
Re: Webbrowser Control Tip and Examples
ok it definitely works now.
to make it wait i used:
Code:
Do Until webbrowser1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
but now i need to figure how to click the "submit" button on the page. How do i go about that?
-
Oct 5th, 2007, 11:13 AM
#65
New Member
Re: Webbrowser Control Tip and Examples
I'm trying to use the "Check if word/string is found on page" code on the first page of this thread, but keep getting an Error 91 message on this line:
Code:
For i = 1 To WebBrowser1.Document.All.length
First i got an object not defined error because "webBrowser1" wasnt Dim'd, so i dim'd it as "Dim webBrowser1 as webbrowser" but now i need to SET it to something - i just dont know what i SET it to. Anyone know?
-
Nov 10th, 2007, 10:14 PM
#66
New Member
Re: Webbrowser Control Tip and Examples
I realize this may sound odd...but can the Webbrowser Control be embedded in a HTML page? If so how would I do it?
I'm building a Folder Home Page to replace my Outlook Today and would like to be able to use it as a file browser right on the page.
-
Nov 11th, 2007, 10:50 AM
#67
Re: Webbrowser Control Tip and Examples
Originally Posted by dch31969
I realize this may sound odd...but can the Webbrowser Control be embedded in a HTML page? If so how would I do it?
I'm building a Folder Home Page to replace my Outlook Today and would like to be able to use it as a file browser right on the page.
Use an iframe element.
-
Nov 11th, 2007, 12:04 PM
#68
New Member
Re: Webbrowser Control Tip and Examples
Originally Posted by penagate
Use an iframe element.
Ok...I know how to put an iframe into a HTML page, but given that I had no idea until yesterday that the WebBrowser control existed, could you please provide me with the syntax? I should be able to figure things out from there.
-
Nov 11th, 2007, 12:17 PM
#69
Re: Webbrowser Control Tip and Examples
sorry, I didn't mean embed the WebBrowser using an iframe, but just point the iframe to the directory you want to browse.
-
Nov 11th, 2007, 02:41 PM
#70
New Member
Re: Webbrowser Control Tip and Examples
Originally Posted by penagate
sorry, I didn't mean embed the WebBrowser using an iframe, but just point the iframe to the directory you want to browse.
So its not possible to present an Explorer like interface complete with folders, drives, files? I'm essentially looking give my users everything that they have when they explore their PCs.
-
Feb 19th, 2008, 12:02 PM
#71
New Member
Re: Webbrowser Control Tip and Examples
That auto submit thing is good With WebBrowser but how do u find the exact Thing to be written like. If i do it on. http://login.yahoo.com Then if i view html code for this page i see Document.Write. So I write it like this
WebBrowser1.Document.Write.passwd.value = strpw
passwd is PASSWORD so it doesnt work
-
Feb 19th, 2008, 12:27 PM
#72
New Member
Re: Webbrowser Control Tip and Examples
Nvm It Works Thanks For The Help By msgjp7
-
May 6th, 2008, 03:19 AM
#73
Member
Re: Webbrowser Control Tip and Examples
Hi, if you know, I need some codes! For the find box (when I start the find box and start searching a word, I want webbrowser to highlight it). I need codes for the right click menu, such as 'Save Picture As...'; 'E-mail Picture'; 'Print Picture'; 'Set as Background'; 'Set as Desktop Item'; 'Copy Shortcut'; 'Add to favorites'; 'Open link'; 'Open link in new window'; 'Save Target as...'; 'Print Target'. I want to know, if I have open form1, how to open a NEW form1 with a commandbutton? Please help with these problems!
-
Aug 29th, 2008, 12:39 AM
#74
Re: Webbrowser Control Tip and Examples
Is there any way to block pop ups.???
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 30th, 2008, 02:02 PM
#75
Lively Member
Re: Webbrowser Control Tip and Examples
Here is my current code:
Code:
Option Explicit
Dim doc As HTMLDocument
Private Sub Command1_Click()
WebBrowser1.Navigate "http://www.google.com"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim i As Long, EHTML
For i = 1 To WebBrowser1.Document.All.length
Set EHTML = _
WebBrowser1.Document.All.Item(i)
If Not (EHTML Is Nothing) Then
If InStr(1, EHTML.innerHTML, "Google", vbTextCompare) > 0 Then
Replace EHTML.innerHTML, "Google", "Boogle"
End If
End If
Next i
doc = WebBrowser1.Document
End Sub
Basically, supposed to replace every Google string with Boogle. Works, as I tested with MsgBox, but the thing is EHTML doesnt writeback to the page, so EHTML is changed, while whats being displayed isn't. Any way to writeback the changes without reloading the page?
-
Oct 19th, 2008, 09:00 PM
#76
Lively Member
Re: Webbrowser Control Tip and Examples
Custom Right Click Menu
This is an example show how to make your own custom right click menu. in order for this to work you must add the "Must Add Microsoft HTML Object Library" to your refrance.Also make your own custom menu using the menu editor I named my "mnu"
Please Note it will effect all the context menus in the webbrowser.
VB Code:
'Must Add Microsoft HTML Object Library
Option Explicit
Public WithEvents HTML As HTMLDocument
Private Function HTML_oncontextmenu() As Boolean
HTML_oncontextmenu = False
PopupMenu mnu '<---Check the mnu to your own menu name
End Function
Private Sub Form_Load()
WebBrowser1.Navigate "www.google.com"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set HTML = Nothing
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, _
URL As Variant)
Set HTML = WebBrowser1.Document
End Sub
Might be bringing an old post back alive but I definately needed help with this. The above code got me started on making my own context menu for the webbrowser control. However, My webbrowser control page that it navigates to has an iframe. When I right click on the iframe it does not keep the contextmenu, is there a way to fix this?
Thanks,
n3m.
-
Oct 22nd, 2008, 03:59 PM
#77
Re: Webbrowser Control Tip and Examples
So, does you example work with IFrames?
Nevermind, I see now you stated that. BTW: I have been working on that problem from your other thread and so far no luck but I am sticking with it since I have learned a few things about frames and things since then so maybe, just maybe, I might be able to figure it iut.
-
Nov 10th, 2008, 06:22 PM
#78
New Member
Re: Webbrowser Control Tip and Examples
Hi. Is there anyway any to get "updated" html code on pages with AJAX? Im working with .net 2008, Webbrowser.
Is there any workarround to solve this?
Thanks.
Ariel
-
Jan 21st, 2009, 06:12 PM
#79
Hyperactive Member
Re: Webbrowser Control Tip and Examples
Hi all,
Thanks for the control tips and examples. I'm developing an Outlook-Addin in VB6 and I'm trying to do what is outlined in 'Making page on startup' as listed below. I'm retriving HTML from a database and would like to display it in the webbrowser control.
Code:
Private Sub Form_Load()
WebBrowser1.Navigate "about:blank"
End Sub
Private Sub Command1_Click()
Dim HTML As String
'----------The HTML CODE GOES FROM HERE AND DOWN----------
HTML = "<HTML>" & _
"<TITLE>Page On Load</TITLE>" & _
"<BODY>" & _
"<FONT COLOR = BLUE>" & _
"This is a " & _
"<FONT SIZE = 5>" & _
"<B>" & _
"programmatically " & _
"</B>" & _
"</FONT SIZE>" & _
"made page" & _
"</FONT>" & _
"</BODY>" & _
"</HTML>"
'----------The HTML CODE GOES HERE AND ABOVE----------
WebBrowser1.Document.Write HTML
End Sub
The problem is that I have no intellisense past WebBrowser1.Document (no .Write). and when I add it, the program errors out.
I have a reference to the Microsoft Internet Controls, but I don't know what is the matter.
Any help would be appreciated.
Thanks,
JB
JazzBass
In the .NET era
Trying to remember VB6
Progress:
XP Professional @ Home
and @ the Office
-
Jan 16th, 2010, 04:38 AM
#80
Addicted Member
Re: Webbrowser Control Tip and Examples
Here's 2 additions:
Requires MSHTML Object Library and the WebBrowser is called wbMain
Waiting for a webpage to load
vb Code:
Option Explicit Private Declare Function GetTickCount Lib "kernel32.dll" () As Long Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) Private m_bDOMReady As Boolean Private WithEvents m_ctlWB As WebBrowser Public Function navigateAndWait(ByVal ctlWebBrowser As WebBrowser, ByRef vData As Variant, Optional ByRef lMaxWaitTimeMillis As Long = 45000) As Boolean On Error GoTo EH Dim lEndTime As Long, obj As IHTMLElement, szURL As String '--Navigate and wait for the web page to load '--vData can be a string(url) or an HTML Object Set m_ctlWB = ctlWebBrowser If (IsObject(vData)) Then Set obj = vData Select Case UCase(obj.tagName) '--Hyperlink reference, like links on a page Case "A" Call ctlWebBrowser.Navigate(obj.href) '--Forms, like login pages Case "FORM" Call obj.submit '--Something else, so try to click it Case Else Call obj.Click End Select Else '--Regular URL szURL = CStr(vData) Call ctlWebBrowser.Navigate(szURL) End If lEndTime = (GetTickCount() + lMaxWaitTimeMillis) m_bDOMReady = False Do While (Not m_bDOMReady) '--Check for timeout If ((lMaxWaitTimeMillis <> -1) And (GetTickCount() > lEndTime)) Then Exit Do '--So app doesnt freeze DoEvents '--Dont kill the CPU Call Sleep(5) Loop If (Not m_bDOMReady) Then Call m_ctlWB.Stop End If Set m_ctlWB = Nothing navigateAndWait = (m_bDOMReady) Exit Function EH: Call Err.Clear navigateAndWait = False End Function Private Sub m_ctlWB_DocumentComplete(ByVal pDisp As Object, URL As Variant) On Error GoTo EH Dim oHTMLDoc As HTMLDocument '--In pages with no frames, this event fires one time after loading is complete. '--In pages where multiple frames are loaded, this event fires for each frame where the DWebBrowserEvents2::DownloadBegin event has fired. '--The top-level frame fires the DocumentComplete in the end. '--So, to check if a page is done downloading, you need to check if the IDispatch* parameter, is same as the IDispatch of the WebBrowser control. If (pDisp Is m_ctlWB.object) Then m_bDOMReady = True ElseIf (TypeOf pDisp.Container Is HTMLDocument) Then Set oHTMLDoc = pDisp.Container If (oHTMLDoc.frames.length = 0) Then m_bDOMReady = True End If End If Exit Sub EH: Call Err.Clear End Sub
Example:
vb Code:
Private Sub cmdGo_Click() Dim oNAW As cNavAndWait, sStart As Single Set oNAW = New cNavAndWait sStart = Timer() Call oNAW.navigateAndWait(wbMain, txtURL.Text) Call MsgBox(txtURL.Text + " took " + CStr(Timer() - sStart) + " seconds to load.", vbOKOnly Or vbInformation, "Navigate And Wait") Set oNAW = Nothing End Sub
How to copy and save an image from a webpage
vb Code:
Option Explicit Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) Private m_bDOMRdy As Boolean Private Sub cmdCopy_Click() Dim pDoc As HTMLDocument, pImgEle As IHTMLImgElement, pCR As IHTMLControlRange, szImgname As String '--Grab the image of the first picture on the page and copy it into the PictureBox Set pDoc = wbMain.Document For Each pImgEle In pDoc.All.tags("IMG") szImgname = Mid(pImgEle.src, InStrRev(pImgEle.src, "/") + 1) '--Create a control range '--MSDN: Contains a range of control type elements that is used for control selection; _ and represents an array of controls that can be operated on as a group. Set pCR = pDoc.body.createControlRange() '--Clear the clipboard Call Clipboard.Clear '--Add the image element Call pCR.Add(pImgEle) '--Copy it to the clipboard Call pCR.execCommand("copy") '--Do what you want with the image since its on the clipboard Set pbPic.Picture = Clipboard.GetData(vbCFBitmap) '--Save the image Call SavePicture(pbPic.Picture, "C:\" + szImgname) Exit For Next pImgEle End Sub Private Sub Form_Load() m_bDOMRdy = False Call wbMain.Navigate("http://frontrowcrew.com/") Do While (Not m_bDOMRdy) DoEvents Call Sleep(10) Loop End Sub Private Sub wbMain_DocumentComplete(ByVal pDisp As Object, URL As Variant) If (pDisp Is wbMain.Object) Then m_bDOMRdy = True End If End Sub
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
|