Navigate to new URL in existing Internet Explorer window

后端 未结 2 838
长发绾君心
长发绾君心 2021-01-14 09:30

I am trying to get an existing (open) IE window to load a new URL via ie.Navigate.

Below is my worksheet code which loads a website on click of a button

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 10:26

    As a similar/adapted alternative, here's a favorite function of mine.

    This function returns an object representing the existing InternetExplorer instance if there is one, otherwise a newly-created instance.

    Function GetIE() As Object
    'return an object for the open Internet Explorer window, or create new one
      For Each GetIE In CreateObject("Shell.Application").Windows() 'Loop to find
        If (Not GetIE Is Nothing) And GetIE.Name = "Internet Explorer" Then Exit For 'Found!
      Next GetIE
      If GetIE Is Nothing Then Set GetIE=CreateObject("InternetExplorer.Application")'Create
      GetIE.Visible = True 'Make IE window visible
    End Function
    

    More information and example here.

提交回复
热议问题