Open a URL with Internet Explorer in a new tab (not a new window)

Posted on 2016-10-06
Last Modified: 2016-10-07
I am trying to get an already running instance of Internet Explorer to add a new tabbed page. This is the Delphi code I start with.:

  Temp : String;
  if FileExists('C:\Program Files (x86)\Internet Explorer\iexplore.exe') then begin
    Temp := '"C:\Program Files (x86)\Internet Explorer\iexplore.exe"';
  if FileExists('C:\Program Files\Internet Explorer\iexplore.exe') then begin
    Temp := '"C:\Program Files\Internet Explorer\iexplore.exe"';
  ShellExecute(Handle, 'open', PChar(Temp), PChar(''), nil, SW_SHOW);

Open in new window

Although this code does display the URL ( in IE, it does so by launching a new instance (new window) of IE rather than in a new tabbed page to the already running instance of IE.  How can I do the latter?
Question by:Fontographer
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 27

Accepted Solution

Sinisa Vuk earned 500 total points
ID: 41833123
I've managed to run multiple tabs using IE ole automation. First, check if iexplore.exe is running. If yes - then use Navigate2 function from that runing instance, but if not found - start new instance...
uses ComObj;
  navOpenInNewWindow = 1;
  navNoHistory = 2;
  navNoReadFromCache = 4;
  navNoWriteToCache = 8;
  navAllowAutosearch = 16;
  navBrowserBar = 32;
  navHyperlink = 64;
  navEnforceRestricted = 128;
  navNewWindowsManaged = 256;
  navUntrustedForDownload = 512;
  navTrustedForActiveX = 1024;
  navOpenInNewTab = 2048;
  navOpenInBackgroundTab = 4096;
  navKeepWordWheelText = 8192;
  navVirtualTab = 16384;
  navBlockRedirectsXDomain = 32768;
  navOpenNewForegroundTab = 65536;

procedure RunIEUrl(sURL: String; param: OleVariant);
  i: Integer;
  ShellWindows: OleVariant;
  ShellApplication: OleVariant;
  IE: OleVariant;
  IE := Unassigned;
  //find running instance - using win shell
  ShellApplication := CreateOleObject('Shell.Application');
  if not VarIsEmpty(ShellApplication) then
    ShellWindows := ShellApplication.Windows;
    for i := 0 to ShellWindows.Count - 1 do
      if UpperCase(ExtractFileName(ShellWindows.Item(i).FullName)) = 'IEXPLORE.EXE' then //check exe name
        IE := ShellWindows.Item(i);
        IE.Navigate2(sURL, param);

  //not found running instance - run new instance
  if VarIsEmpty(IE) then
    IE := CreateOleObject('InternetExplorer.Application');
    IE.Visible := true;

procedure TForm1.Button1Click(Sender: TObject);
  RunIEUrl(Edit1.Text, navOpenInNewTab);

Open in new window

Fill Edit1 with a web site url....

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question