Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel in IE - opening new window

We create binary XLS files(using the MS Excel BIFF8
specification) for our content. Our users can access these
XLS files on our web site via HTTP requests. Upon request,
IE opens an instance of Excel in the browser window and
displays the XLS file.

There are links in the spreadsheet to "source data"(HTML
files). We want to encode these HTTP links within the
binary XLS file so users can view the "source data" (HTML).

Currently, when you click on one of these links, the HTML
file opens in the same browser window. We are trying to
open the HTML file in a NEW browser window and give it
focus. This way, our users can view the XLS file and HTML
file(source document) side-by-side.

Here's what we tried so far. All attempts have been
unsuccessful.

Using the Script Editor in Excel, we created an <a tag
around the link text and added the target="_blank"
attribute. Excel seemed to ignore this.

Next, we tried using the JavaScript window.open method in
the HREF. This method spawned a new window for our HTML
file, but the existing browser window that contained the
XLS file became blank, well, actually
contained "[object]". It seemed like Excel populated the
new URL,"javascript:window.open('http://...)", in this
window instead of retaining the existing XLS file.

Next, we added document.location.href='{entered path to
XLS file}' to the HREF, and this almost worked. A new
browser window successfully opened with our HTML file, and
our original browser window "reloaded" the XLS file. The
problem was that upon this "reload", we got the
Excel "File Download" dialog box telling us that these
files could be harmful and asking if we wanted to open it,
save it, ... We click Open and everything works fine, but
the XLS file has focus now, instead of the HTML file.
Although both windows are open, you can't easily tell that
the HTML file has been opened.

We tried to change focus by adding some JavaScript to the
<body tag of the XLS file, but that didn't work either.

Finally, I found this on MSDN. This is exactly the problem
we're seeing but both solutions failed to work for us.
http://support.microsoft.com/default.aspx?scid=kb;en-
us;257321

Any help on this matter would be greatly appreciated.

Chris Marino
Senior Web Developer
Edgar Online, Inc.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Excel in IE - opening new window

Hi Chris,

Unless you're saving as HTML, I think you're correct in that Excel will
ignore the new window requests. If you put in the target="_blank" and save
as HTML, then it will work as expected. But I'm guessing you need to serve
the files in XLS format.

The only way I could get this to work is to use the
Worksheet_FollowHyperlink event. Basically, you would add the hyperlink to
the worksheet, but make it hyperlink to itself (the cell the hyperlink is
in), which effectively makes it go nowhere. The TextToDisplay property
would be used to specify the URL for the link. Then, in the FollowHyperlink
event, you could do something like this:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ThisWorkbook.FollowHyperlink Target.TextToDisplay, , True
End Sub

The drawback to this method is that the macro security dialog will pop up
since you have added VBA code.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Chris Marino wrote:
We create binary XLS files(using the MS Excel BIFF8
specification) for our content. Our users can access these
XLS files on our web site via HTTP requests. Upon request,
IE opens an instance of Excel in the browser window and
displays the XLS file.

There are links in the spreadsheet to "source data"(HTML
files). We want to encode these HTTP links within the
binary XLS file so users can view the "source data" (HTML).

Currently, when you click on one of these links, the HTML
file opens in the same browser window. We are trying to
open the HTML file in a NEW browser window and give it
focus. This way, our users can view the XLS file and HTML
file(source document) side-by-side.

Here's what we tried so far. All attempts have been
unsuccessful.

Using the Script Editor in Excel, we created an <a tag
around the link text and added the target="_blank"
attribute. Excel seemed to ignore this.

Next, we tried using the JavaScript window.open method in
the HREF. This method spawned a new window for our HTML
file, but the existing browser window that contained the
XLS file became blank, well, actually
contained "[object]". It seemed like Excel populated the
new URL,"javascript:window.open('http://...)", in this
window instead of retaining the existing XLS file.

Next, we added document.location.href='{entered path to
XLS file}' to the HREF, and this almost worked. A new
browser window successfully opened with our HTML file, and
our original browser window "reloaded" the XLS file. The
problem was that upon this "reload", we got the
Excel "File Download" dialog box telling us that these
files could be harmful and asking if we wanted to open it,
save it, ... We click Open and everything works fine, but
the XLS file has focus now, instead of the HTML file.
Although both windows are open, you can't easily tell that
the HTML file has been opened.

We tried to change focus by adding some JavaScript to the
<body tag of the XLS file, but that didn't work either.

Finally, I found this on MSDN. This is exactly the problem
we're seeing but both solutions failed to work for us.
http://support.microsoft.com/default.aspx?scid=kb;en-
us;257321

Any help on this matter would be greatly appreciated.

Chris Marino
Senior Web Developer
Edgar Online, Inc.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Excel sheet in its own window prpc Setting up and Configuration of Excel 4 July 13th 07 01:36 PM
Opening an Excel link in new window Kathrynne Excel Discussion (Misc queries) 0 July 10th 07 08:10 PM
opening excel docs in a new window Andy Excel Discussion (Misc queries) 5 March 7th 07 10:53 PM
Opening excel in a new window sebire Excel Discussion (Misc queries) 4 January 5th 07 04:32 PM
Opening excel file in new window Ravi Excel Discussion (Misc queries) 7 October 19th 05 05:46 PM


All times are GMT +1. The time now is 06:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"