Jul 20, 2009 09:13 AM|ChristianPedersen|LINK
First off, I apologize if this is the incorrect place to put this question. I was unsure where to stick it and selected the clientside section because in all honesty, this is a problem that's located on the client's computer. :)
I have a simple ASP.Net site with a bunch of LinkButtons that all point to the same XLT-file on the server. The LinkButtons, when clicked, set some values in a table in a database, and then they open the XLT-file by using Response.TransmitFile. See code
below. The XLT-file has some VBA macros in it (that I didn't write) which contact the same database the LinkButtons wrote to in order to retrieve the name of the table in the link that was clicked. Then the macros fill the Excel workbook with values from this
This is all fine and dandy, so far... The problem is when you attempt to open multiple instances, i.e. when you click on more links. The first time I click a link, I get the option to Open, Save or Cancel. I click Open, and Excel correctly opens, the macros
kick in, and I see values. When I click a second link, a new window is supposed to open and values pertaining to the other link are supposed to display in it. Instead, the original Excel application is merely brought up and given focus, like if I'd clicked
its button in the taskbar, and nothing happens. I see only the Workbook window with the values from the first link in it. I don't get a new option to Open, Save or Cancel, and I get no new Excel instance or Workbook window.
Interestingly, this is an IE thing. It works perfectly well in FireFox. Here, it asks me if I want to open or save the file every time I click a link, and if I select Open, it simply gives me multiple instances of the entire Excel application. To begin with,
I thought this might've been because all the links point to the same XLT-file and Windows somehow detects that the file is already open when I click the second link, but this isn't the case. I put in a button that opens an XLT-file with a different name just
to test it, and it had the same behavior.
Anybody know how I can fix this? I've already tried a lot of the solutions involving the addition of "%1" to the File Type advanced settings as well as disabling DDE in order to force new, seperate applications to open, and none of them work.
All help greatly appreciated!
void OpenLink_Click(object sender, EventArgs e)
// Recover tablename of the linkbutton that was clicked
string tablename = ((LinkButton)sender).ID;
*Do stuff here that writes data to the database that the Excel VBA Macros also access*
// Transmit the file to the user. I tried to use Response.Redirect to begin with, but that allowed the users to open the file remotely, and then the macros didn't work, so I had to use TransmitFile in order to force a download:
System.IO.FileInfo TanarosTemplateFile = new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "Tanaros.xlt");
//Response.ContentType = "application/vnd.ms-excel";
Response.ContentType = "application/msexcel";