Opening Word and Excel - ActiveX

D

David C

I have an intranet aspnet page that uses Attributes.Add to populate an
onclick event in a DataGrid that displays files in a directory. Everything
works fine as far as displaying the file names and creating hyperlinks to
call an ActiveX object in Javascript. The function to open Microsoft Word
works perfectly but the same exact process for Excel does not. I also found
in testing that if I add "file:" to the path then Word and the file open
fine. When I try the same with Excel it tells me it cannot find the name.
Can anyone see what might be wrong?

Below is what shows in the view source of the page:

<a
onclick="openWord('file:\\server\\shared\\FileDocs\\File090216\\0009Quarles
and Brady (Misc-No File Num)\\Check Requests - Bad Invoice Dates.doc');"
id="articleList_ctl03_LBtnOpen"
href="javascript:__doPostBack('articleList$ctl03$LBtnOpen','')">Word</a>

<a
onclick="openExcel('file:\\server\\shared\\FileDocs\\File090216\\0009Quarles
and Brady (Misc-No File Num)\\Fileroom Company List.xls');"
id="articleList_ctl04_LBtnOpen"
href="javascript:__doPostBack('articleList$ctl04$LBtnOpen','')">Excel</a>

And these are my javascript functions:

function openWord(spath)
{
var wdApp = new ActiveXObject("Word.Application");
wdApp.Visible = 'True';
var wdDoc = wdApp.Documents;
wdDoc.Open(spath);
}
function openExcel(spath)
{
var xlApp = new ActiveXObject("Excel.Application");
xlApp.Visible = 'True';
var wb = xlApp.Workbooks;
wb.Open(spath);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top