Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: aspnet page javascript Word/Excel

Posted on 2008-04-08 23:24:33 by 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\\File0902 16\\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\\File090 216\\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);
}

Below is my ItemDataBound subroutine:

Protected Sub articleList_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs)
' First, make sure we are NOT on a Header or Footer row
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
Dim strFileName As String =
Convert.ToString(DataBinder.Eval(e.Item.DataItem, "Name"))
If Left(strFileName, 1) <> "~" Then
strFileName = Replace(strFileName, Chr(35), "@@")
Dim strNewFile As String = ""
Dim varControl
varControl = e.Item.FindControl("HLFile")
varControl.NavigateURL = "ShowDocs.aspx?doc=" & strFileName
Dim strFullPath As String = strPathPhy & "\" & strFileName
varControl = e.Item.FindControl("LBtnOpen")
Select Case LCase(Right(strFileName, 3))
Case "doc"
strNewFile = Replace(strFullPath, "\", "\\", 3)
strNewFile = Replace(strNewFile, "@@", Chr(35))
varControl.Attributes.Add("onclick",
"openWord('file:\\" & strNewFile & "')")
varControl.Text = "Word"

Case "xls"
strNewFile = Replace(strFullPath, "\", "\\", 3)
strNewFile = Replace(strNewFile, "@@", Chr(35))
varControl.Attributes.Add("onclick",
"openExcel('file:\" & "\" & strNewFile & "')")
varControl.Text = "Excel"

Case Else
varControl.Text = ""

End Select
End If
End If
End Sub

Report this message