Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateObject("InternetExplorer.Application") Error

1,813 views
Skip to first unread message

WyleySam

unread,
Sep 16, 2004, 3:47:54 PM9/16/04
to
I am trying to write a VB6 app that opens the Internet Explorer. I have
copied several examples but keep getting the same error when trying to
execute the CreateObject command:

Run-time error '13': Type mismatch

Code:
Public IE As InternetExplorer

Private Sub Command1_Click()

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate2 "http://visualbasic.about.com"

End Sub


Can anyone help??? I am using VB6 SP6 on a WinXp Home SR2 PC.


Dave Lewis

unread,
Sep 16, 2004, 7:38:58 PM9/16/04
to
Try This

Add a Module with this as one line:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal
hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long)
As Long

To a Form add this, add a button to the form:
Private Sub Command1_Click()
Dim OpenMM As String
OpenMM = "http://www.google.co.uk"
ShellExecute hwnd, "open", OpenMM, vbNullString, vbNullString, conSwNormal
End Sub


Dave L


"WyleySam" <wyle...@comcast.net> wrote in message
news:J5m2d.55992$MQ5.38590@attbi_s52...

Lee Weiner

unread,
Sep 16, 2004, 10:20:53 PM9/16/04
to
In article <J5m2d.55992$MQ5.38590@attbi_s52>, "WyleySam" <wyle...@comcast.net> wrote:
>I am trying to write a VB6 app that opens the Internet Explorer. I have
>copied several examples but keep getting the same error when trying to
>execute the CreateObject command:
>
> Run-time error '13': Type mismatch
>
>Code:
>Public IE As InternetExplorer
>
>Private Sub Command1_Click()
>
> Set IE = CreateObject("InternetExplorer.Application")
> IE.Visible = True
> IE.Navigate2 "http://visualbasic.about.com"
>
>End Sub
>

I pasted your code and added a reference to the Microsoft Internet Controls
to the project and your code worked perfectly.

Lee Weiner
lee AT leeweiner DOT org

mayayana

unread,
Sep 16, 2004, 10:28:16 PM9/16/04
to
I think the problem is that you've got an early-bound
declaration with a late-bound method of creating
the object. If you add a reference to "Microsoft Internet Controls"
(SHDOCVW.DLL) you should be able to do:
Public IE as .... and find "InternetExplorer" in the popup menu.
So then you have what you wrote, which is early-bound,
and you can use that as follows:

Public IE As InternetExplorer
Set IE = New InternetExplorer

Using CreateObject is late-bound. It doesn't know
about InternetExplorer. CreateObject just uses a generic
COM Object:

Public IE as Object


Set IE = CreateObject("InternetExplorer.Application")

The early-bound version is better because it compiles
the necessary typelib data into your EXE, so that your
program knows about IE. The late-bound version needs
to look up the external typelib when it's created.

(You can also just use a WebBrowser control on
a form. A WB is the same thing as the IE browser
window. Their properties and methods are either
identical or close to it.)


--
--


WyleySam <wyle...@comcast.net> wrote in message
news:J5m2d.55992$MQ5.38590@attbi_s52...

WyleySam

unread,
Sep 17, 2004, 12:36:21 PM9/17/04
to
Mayayana,

Tried this now I get the following error:

Run-time error '430': Class does not support Automation or does not
support expected interface

Neil

"mayayana" <mayaXX...@mindYYspring.com> wrote in message
news:4Zr2d.4114$mb6....@newsread3.news.atl.earthlink.net...

Gary

unread,
Sep 17, 2004, 1:48:45 PM9/17/04
to
This is what I did:

First add this to (General)(Declarations):
Private Declare Function WinExec Lib "kernel32" (ByVal _
lpCmdLine As String, ByVal nCmdShow As Long) As Long

Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_NORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Const SW_MAXIMIZE = 3
Const SW_SHOWNOACTIVE = 4
Const SW_SHOW = 5
Const SW_MINIMIZE = 6
Const SW_SHOWMINNOACTIVE = 7
Const SW_SHOWNA = 8
Const SW_RESTORE = 9
Const SW_SHOWDEFAULT = 10
Const SW_MAX = 10
---
Then add this code to the button you want to use to fire off IE:

Call WinExec("C:\Program Files\Internet Explorer\iexplore.exe", 1)

---
Works like a charm. Of course, you don't have to add the Const statements,
it's just helpful if - say you want to open the form Maximized, Minimized,
etc.

hth,
Gary


"WyleySam" <wyle...@comcast.net> wrote in message
news:J5m2d.55992$MQ5.38590@attbi_s52...

mayayana

unread,
Sep 17, 2004, 5:15:38 PM9/17/04
to
I don't understand. You tried what?
I just ran the following code in a form and it worked fine:

---------begin form1----------------------------
Option Explicit
Dim IE As InternetExplorer

Private Sub Command1_Click()
Set IE = New InternetExplorer
IE.Navigate "about:blank"
IE.Visible = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set IE = Nothing
End Sub

--------------- end form1 code -----------------------

When I click Command1 I get an IE window with
about:blank.

WyleySam

unread,
Sep 20, 2004, 10:29:25 AM9/20/04
to
I tried the code below and I am now getting the 430 (Class does not support
Automation or does not support expected interface)

.


"mayayana" <mayaXX...@mindYYspring.com> wrote in message

news:_tI2d.5060$n16....@newsread2.news.atl.earthlink.net...

mayayana

unread,
Sep 20, 2004, 6:55:50 PM9/20/04
to
It worked fine for me. Internet Explorer has a usable
Automation interface. There are only two things
that I can think of:

1) You didn't reference Microsoft Internet Controls.
(You should be able to find an InternetExplorer object
in the object browser. If not then the reference is missing.)

2) You're on XP and have installed SP2. SP2 makes a mess
of IE settings and I've read in the WebBrowser newsgroup
that some people are also having problems with WB functions
that are no longer working under SP2.
I don't think that SP2 would be blocking IE automation
altogether, but it's the only other clue that I can think of.

You can test that by checking for the Registry values
(in HKLM and HKCU)
Software\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_LocalMachine_Lockdown\IExplore.exe

If either value exists set it to 0 instead of 1.

0 new messages