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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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