+ Reply to Thread
Results 1 to 2 of 2

IE not detected

  1. #1
    Jagruti
    Guest

    IE not detected

    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


  2. #2
    Ron de Bruin
    Guest

    Re: IE not detected

    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


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "Jagruti" <[email protected]> wrote in message news:[email protected]...
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1