How do you call an instance of INTERNETEXPLORER in VB?
eg Shell( " INTERNETEXPLORER.exe ") BUT in Windows the file name is not INTERNETEXPLORER, what is it??
Also do we need to Declare the InternetExplorer Object, & how?
Rgds
Lothar Haensler
February 21st, 2000, 01:41 AM
dim ie as object
set ie = createobject("InternetExplorer.Application")
from now on use automation to trigger IE.
Btang11111
February 21st, 2000, 07:57 AM
Hi,
I coded IE Object, but it does not show up. Am I not using the Automation properly here to trigger IE.
Also, do I need to declare something...before I can use events like
IE_BeforeNavigate2 instead of WebBrowser1_BeforeNavigate2 (of WebBrowser Event Controls)
Thanks
Option Explicit
Dim CONNECTED As Boolean
Dim ie As Object
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as string, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Public Function IsConnected() As Boolean
Dim lRegKey As Long
Dim bData(3) As Byte
If RegOpenKey(HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\RemoteAccess", lRegKey) = 0 Then
'Opened RegKey Successfully..
If RegQueryValueEx(lRegKey, "Remote Connection", 0&, 1&, bData(0), 4) = 0 Then
'Query the Value of "Remote Connection" 1 - Connected, 0 - Not Connected
IsConnected = bData(0)
Else
'Counldn't find the Value, assume no Connection
IsConnected = False
End If
'Close the Registry Key
Call RegCloseKey(lRegKey)
End If
End Function
Private Sub Form_Load()
Shell ("adialer.exe /d")
Do
CONNECTED = IsConnected()
If CONNECTED = True Then
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://www.microsoft.com"
End If
Loop Until CONNECTED = True
End Sub
Private Sub ie_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Shell ("adialer.exe /d")
Do
CONNECTED = IsConnected()
Loop Until IsConnected() = True
End Sub
Lothar Haensler
February 21st, 2000, 08:01 AM
you need to set
ie.visible = true
to make IE visible.
Lothar Haensler
February 21st, 2000, 08:13 AM
here is a complete sample
option Explicit
Dim withevents ie as InternetExplorer
private Sub Command1_Click()
set ie = new InternetExplorer
ie.Visible = true
ie.Navigate2 "yourURL"
End Sub
private Sub ie_DownloadComplete()
MsgBox "downloaded"
End Sub
private Sub ie_NavigateComplete2(byval pDisp as Object, URL as Variant)
MsgBox "navigated"
End Sub
watch the WithEvents in the Dim statement. You need that to trap the events.
Btang11111
February 21st, 2000, 10:52 AM
Hi,
Code is tidy.
I use Visual Studio v.6 BUT had this Error Msg 430 below?!
here is a complete sample
option Explicit
Dim withevents ie as InternetExplorer
Private Sub Command1_Click()
set ie = new InternetExplorerie ----->** ERROR 430 Doesn't support Automation
ie.Visible = true or Not expecting this class** interface
ie.Navigate2 "yourURL"
End Sub
private Sub ie_DownloadComplete()
MsgBox "downloaded"
End Sub
private Sub ie_NavigateComplete2(byval pDisp as Object, URL as Variant)
MsgBox "navigated"
End Sub
watch the WithEvents in the Dim statement. You need that to trap the events.
Lothar Haensler
February 21st, 2000, 10:56 AM
sorry, you need to add a reference to shdocvw.dll to make it work.
That DLL contains the InternetExplorer "object".
Btang11111
February 21st, 2000, 10:59 AM
Hi,
complete sample below
Option Explicit
Dim CONNECTED As Boolean
Dim WithEvents ie As InternetExplorer
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as string, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Public Function IsConnected() As Boolean
Dim lRegKey As Long
Dim bData(3) As Byte
If RegOpenKey(HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\RemoteAccess", lRegKey) = 0 Then
'Opened RegKey Successfully..
If RegQueryValueEx(lRegKey, "Remote Connection", 0&, 1&, bData(0), 4) = 0 Then
'Query the Value of "Remote Connection" 1 - Connected, 0 - Not Connected
IsConnected = bData(0)
Else
'Counldn't find the Value, assume no Connection
IsConnected = False
End If
'Close the Registry Key
Call RegCloseKey(lRegKey)
End If
End Function
Private Sub Form_Load()
Shell ("adialer.exe /d")
Do
CONNECTED = IsConnected()
If CONNECTED = True Then
Set ie = New InternetExplorer **ERROR MSG 430 **
ie.Visible = True
ie.Navigate "http://www.microsoft.com"
End If
Loop Until CONNECTED = True
End Sub
Private Sub ie_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Shell ("adialer.exe /d")
Do
CONNECTED = IsConnected()
Loop Until IsConnected() = True
End Sub
Btang11111
February 21st, 2000, 11:27 AM
Hi,
same Error Msg 430 after replacing INTERNETEXPLORER with SHDocVwCt1.INTERNETEXPLORER.
Pls show REFERENCE codes for SHDocVwCt1.
OR perhaps we need to create an EVENT SINK, & hook the EVENT SINK with an instance of the INTERNETEXPLORER??
option Explicit
Dim withevents ie as SHDocVwCtl.InternetExplorer
private Sub Command1_Click()
set ie = new SHDocVwCtl.InternetExplorer **ERR MSG 430 **
ie.Visible = true
ie.Navigate2 "yourURL"
End Sub
private Sub ie_DownloadComplete()
MsgBox "downloaded"
End Subprivate Sub
ie_NavigateComplete2(byval pDisp as Object, URL as Variant)
MsgBox "navigated"
End Sub
Btang11111
February 21st, 2000, 04:34 PM
Hi,
Thanks very much, WELL DONE! It works after I click on Reference Command (instead of Component Command)in Project Menu, Scroll to Microsoft internet Control (shdocvw.dll) reference & check the check box.
Rgds
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.