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.
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...
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
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...
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...
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...
---------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.
.
"mayayana" <mayaXX...@mindYYspring.com> wrote in message
news:_tI2d.5060$n16....@newsread2.news.atl.earthlink.net...
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.