How to get links in Excel to open in single browser tab

11,780

Solution 1

Depends on which browser you are using:

For Firefox, see this link Force Firefox To Open Links In Same Tab

Requires setting option in about:config browser.link.open_newwindow = 1

For IE, Tools/options/General/Tabs/Setings

Open links from other programs in: The current Tab or Window

Solution 2

Try using Spreadsheet::WriteExcel

#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;

# Create a new workbook called simple.xls and add a worksheet
my $workbook  = Spreadsheet::WriteExcel->new('Example.xls');
my $worksheet = $workbook->add_worksheet();

# The general syntax is write($row, $column, $token). Note that row and
# column are zero indexed
# Write a hyperlink
$worksheet->write(10, 0, 'http://perldoc.perl.org/');
$worksheet->write(11, 0, 'http://stackoverflow.com/');

__END__  

the hyperlinks are opened in same browser tabs(works fine in IE,Firefox,Chrome)

Share:
11,780
Steve
Author by

Steve

Updated on June 05, 2022

Comments

  • Steve
    Steve almost 2 years

    I have an Excel spreadsheet with html links in one column. The links are being generated by a perl script via Win32::OLE like so (inside a loop with index $i):

    my $range = $Sheet->Range("B".$row);
    my $link = "http://foobar.com/show.pl?id=$i";
    $Sheet->Hyperlinks->Add({Anchor=>$range,Address=>$link,TextToDisplay=>"Link to $i"});
    

    Currently, every time I click one of these links, it opens in a new browser tab. Since there are a lot of these links I wind up with 20 tabs after working with the sheet for a while. This is a pain in the behind because I periodically have to go through and close them.

    Is there some way to get these links to open in the same browser tab? I don't know if it's possible to specify the HTML equivalent of an anchor target with a constant name using the Hyperlinks->Add method, or if this would even do the job.