IE not detected

  • Thread starter Thread starter Jagruti
  • Start date Start date
J

Jagruti

Hi all,
Sorry to repost but my earlier post posted thru
excelforums did not appeared on this news group.

I am new here but would like to post one problem.
I have developed a application that uses IE for querrying
data from our intranet servers(majority code was picked up
from this NG and tweeked to my requirement)

I have noticed that the application always opens a new
instance of the IE. I tried all the solutions available on
this NG but no joy. If IE is open, I would like to use the
same for my application. Do I need any referance missing?

Code below gives me runtime error 429 "Activex componant
can't create object"

If I comment out the on error resume next statement, code
always create new instance of IE even if IE is already
running.
Please guide me.
Jagruti


Here is my code :
Sub detect_IE()
Dim mybrowser As Object
On Error Resume Next
Set mybrowser = GetObject(, "InternetExplorer.Application")
If Err.Number = 429 Then
Set mybrowser = CreateObject
("Internetexplorer.application")
mybrowser.Visible = True
Err.Clear
End If
With mybrowser
..navigate "http://www.google.com"
End With

On Error GoTo 0

End Sub
 
Hi Jagruti

Copy this in a normal module

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private 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


Public Sub RunShellExecute(ByVal sFile As Variant)
Dim hWndDesk As Long
Dim success As Long
Const SE_ERR_NOASSOC = &H31
hWndDesk = GetDesktopWindow()
success = ShellExecute(hWndDesk, "Open", sFile, 0&, 0&, 3)
End Sub

Sub Run1()
RunShellExecute "http://www.google.com"
End Sub

Sub Run2()
RunShellExecute "http://www.msn.com"
End Sub

Sub Run3()
RunShellExecute "http://www.nu.nl"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top