Controling Internet Explorer?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oldbitcollector

    Controling Internet Explorer?

    I'm a still new to visual basic, and I've hit a problem
    I can't find a workaround for.

    I'm attempting to open and close an Internet Explorer window
    using visual basic 6. I've got the open working properly,
    but for some reason, I can't close the browser when I'm finished with
    it.

    Here's the code I'm using for opening and closing
    =============== =============== =============== ========

    'setup for web popups
    Dim oIE
    Set oIE = CreateObject("I nternetExplorer .Application")

    ' Open a URL upon command %
    If Left$(CurrentCo mmandString, 1) = "%" Then
    oIE.Visible = True
    oIE.navigate Mid$(CurrentCom mandString, 2, T - 2)

    ' Close the Internet Explorer window upon command
    ElseIf Left$(CurrentCo mmandString, 2) = "@%" Then
    oIE.Quit
    oIE.Visible = False

    Endif
    =============== =============== =============== =========

    I've tried oIE.Quit, oIE.Visible=Fal se nothing works,
    unless I place the commands right after the open routine.

    Can anyone assist?

    Jeff

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
  • mayayana

    #2
    Re: Controling Internet Explorer?

    IE.Quit works in script. Maybe you're calling it
    before the instance is fully instantiated?

    Two thoughts:

    1) Don't create an IE instance until you know
    that you'll need it. That's a lot of work going on
    behind the scenes only to dump it if your string
    isn't valid.

    2) Use a WebBrowser control on a form instead
    of creating IE. A WB is actually an IE window and
    uses the IE object methods, but you've got better
    control of it. (Get a WB into your toolbox by setting
    a reference to "Microsoft Internet Controls".
    --
    _______________ ______________

    mayayXXana1a@mi ndYYspring.com
    For return email remove XX and YY.
    _______________ ______________
    Oldbitcollector <oldbitcollecto r@mytrashmail.c om> wrote in message
    news:MPG.1c8418 acf8eae2f79896a 9@news.zoominte rnet.net...[color=blue]
    > I'm a still new to visual basic, and I've hit a problem
    > I can't find a workaround for.
    >
    > I'm attempting to open and close an Internet Explorer window
    > using visual basic 6. I've got the open working properly,
    > but for some reason, I can't close the browser when I'm finished with
    > it.
    >
    > Here's the code I'm using for opening and closing
    > =============== =============== =============== ========
    >
    > 'setup for web popups
    > Dim oIE
    > Set oIE = CreateObject("I nternetExplorer .Application")
    >
    > ' Open a URL upon command %
    > If Left$(CurrentCo mmandString, 1) = "%" Then
    > oIE.Visible = True
    > oIE.navigate Mid$(CurrentCom mandString, 2, T - 2)
    >
    > ' Close the Internet Explorer window upon command
    > ElseIf Left$(CurrentCo mmandString, 2) = "@%" Then
    > oIE.Quit
    > oIE.Visible = False
    >
    > Endif
    > =============== =============== =============== =========
    >
    > I've tried oIE.Quit, oIE.Visible=Fal se nothing works,
    > unless I place the commands right after the open routine.
    >
    > Can anyone assist?
    >
    > Jeff
    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet[/color]
    News==----[color=blue]
    > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+[/color]
    Newsgroups[color=blue]
    > ----= East and West-Coast Server Farms - Total Privacy via Encryption[/color]
    =----


    Comment

    • mayayana

      #3
      Re: Controling Internet Explorer?

      IE.Quit works in script. Maybe you're calling it
      before the instance is fully instantiated?

      Two thoughts:

      1) Don't create an IE instance until you know
      that you'll need it. That's a lot of work going on
      behind the scenes only to dump it if your string
      isn't valid.

      2) Use a WebBrowser control on a form instead
      of creating IE. A WB is actually an IE window and
      uses the IE object methods, but you've got better
      control of it. (Get a WB into your toolbox by setting
      a reference to "Microsoft Internet Controls".
      --
      _______________ ______________

      mayayXXana1a@mi ndYYspring.com
      For return email remove XX and YY.
      _______________ ______________
      Oldbitcollector <oldbitcollecto r@mytrashmail.c om> wrote in message
      news:MPG.1c8418 acf8eae2f79896a 9@news.zoominte rnet.net...[color=blue]
      > I'm a still new to visual basic, and I've hit a problem
      > I can't find a workaround for.
      >
      > I'm attempting to open and close an Internet Explorer window
      > using visual basic 6. I've got the open working properly,
      > but for some reason, I can't close the browser when I'm finished with
      > it.
      >
      > Here's the code I'm using for opening and closing
      > =============== =============== =============== ========
      >
      > 'setup for web popups
      > Dim oIE
      > Set oIE = CreateObject("I nternetExplorer .Application")
      >
      > ' Open a URL upon command %
      > If Left$(CurrentCo mmandString, 1) = "%" Then
      > oIE.Visible = True
      > oIE.navigate Mid$(CurrentCom mandString, 2, T - 2)
      >
      > ' Close the Internet Explorer window upon command
      > ElseIf Left$(CurrentCo mmandString, 2) = "@%" Then
      > oIE.Quit
      > oIE.Visible = False
      >
      > Endif
      > =============== =============== =============== =========
      >
      > I've tried oIE.Quit, oIE.Visible=Fal se nothing works,
      > unless I place the commands right after the open routine.
      >
      > Can anyone assist?
      >
      > Jeff
      >
      > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet[/color]
      News==----[color=blue]
      > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+[/color]
      Newsgroups[color=blue]
      > ----= East and West-Coast Server Farms - Total Privacy via Encryption[/color]
      =----


      Comment

      • Achim Reichel

        #4
        Re: Controling Internet Explorer?

        Hello,

        try to use

        Dim WithEvents oIE As InternetExplore r

        instead of the simple Dim

        Greetings

        Achim Reichel, Gernany


        Comment

        Working...