Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with WebBrowser activeX control

Status
Not open for further replies.

ordendelfai

Technical User
Nov 8, 2002
187
US
Hi All,

Found some info on using this activeX control, specifically the below helped:


However, I can't do anything with the WebBrowser because as soon as I come out of design mode on the form, I get an error stating "There is no Object in this Control". I get this error regardless if I have attached any code or not to the form to work with the control. I know this control is supposed to work if you have IE Explorer 3.0 or higher, so not sure why this is happening.

Any ideas?
 
I apologize, when there is no code the form in the oncurrent event, the error does not occur. Can't get this code to work however. I'd be just as happy with less complicated code (like ActiveXCtl48.Navigate URL:=[Website], which also does not work )

Private Sub Form_Current()
Dim varFull As Variant, varDescription As Variant
Dim HyperlinkAddress As String, HyperlinkSubAddress As String
Dim msg1 As String, msg2 As String, rst As Recordset, strDisplay As String

On Error Resume Next
Set rst = Me.RecordsetClone
'rst.Bookmark = Me.Bookmark
varFull = rst!Website
If IsNull(varFull) Then GoTo Current_Err
varDescription = rst!Description
Me!ActiveXCtl48.Navigate HyperlinkPart(varFull, acAddress)
If Err = 438 Then Exit Sub
'gvarBookMark = Me.Bookmark
Current_Bye:
Exit Sub
Current_Err:
msg1 = "Invalid hyperlink address. Remove the record described as '"
msg2 = "' from the Links table or edit the hyperlink to supply a valid address."
MsgBox msg1 & rst!Description & msg2

'Me.Bookmark = gvarBookMark
Exit Sub
 
Hmmm..If i double click on the control, I get an error about the OLE Server not being installed or something to that nature. If you know of anything let me know. I'll have to check with the real brains (*cough*) in IS.

~Orden
 
This I know works. Assuming you are storing webaddresses in a field and would like to have a combobox display these URL's.

Just follow these steps. When you type in Navigate as a method, it will not show up in the droplist. Don't panic.

Create a table with a field to store web addresses. Create a form and at the top place a combo box bound to this field with a label like:
Web Address [___________]. Name the combobox WebAddress. Next to it place a command button with the function ADD to allow the users to add new addresses to the table.

If you have Internet Explorer on your computer, you already have the Microsoft Web Browser Control (an ActiveX control). (you know, these are written by X-Men).

1) Go to design view of the form. Click on Insert, ActiveX Control.
2) Select Microsoft Web Browser Control. Click OK. Reposition the control so it doesn't hide the combo box. Resize it with the little squares (sizing handles) so it fills the rest of the form.
3) Bring up it's property sheet. Change the name, call it
BrowserControl.

Now you need to write some code. You will use the Navigate method of the control to display a web site.

1) Select the whole form (upper square left hand corner). On the forms property sheet, click on the OnLoad event, click on the build button, select code builder. Type the following:

Private Sub Form_Load() 'don't have to type this
BrowserControl.Navigate "
So, when the form opens it will have a site already there.

Return to your form.
Click the Web Address combo box. Bring up its property sheet. Click on the AfterUpdate event, click on the build button, select Code builder.
Type the following line between the Sub and End Sub:

BrowserControl.Navigate WebAddress

It will now navigate to the web address either selected by the dropdown arrow or typed in by the user.

This is a good start.

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top