Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to launch launch .pdf and word docs from web app

Status
Not open for further replies.

majordog

Programmer
Jul 8, 2002
222
0
0
CA
Hey All,

Hoping someone can give me a helping hand. I think I am on the right track but not sure. I have a reporting web site, ASP.Net and VB.Net (VS 2003) I export the reports to .pdf, .rpt and .doc files. This all works fine. However, when I try and launch these files I get nothing. I was going to use the old ShellExecute function but I understand that it will eventually be phased out and a new Namespace has replaced it: The System.Diagnostics which exposes processes to launch external applications. If I am misusing this or misunderstanding it's purpose..? I am using this code with no results:

Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process
Dim myProcessInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo
Dim strFile As String

Select Case strPrintOption
Case "MS Word (DOC)"
strFile = "Word.doc"
Case "MS Excel (XLS)"
strFile = "Excel.xls"
Case "Portable Document (PDF)"
strFile = "PortableDoc.pdf"
Case "Rich Text (RTF)"
strFile = "RichTextFormat.rtf"
End Select

myProcessInfo.UseShellExecute = True
Dim strTest As String = Request.PhysicalApplicationPath + "Exported\" & strFile
myProcessInfo.FileName = strTest
blnReport = True
myProcess.Start(myProcessInfo)
 
Well, keep in mind that when you execute that code it will execute on the web server, not on the client.

Couple of ways you can do this:

1. Are the reports pre-made and not on the fly? If so, you could just put up hyper-links on the site so that when the client clicks it, the file will be downloaded, and if they have the application on their machine it will launch.

2. If the reports are made on the fly, you can still accomplish this. All you have to do is generate the reports on an on-click, then either response.redirect to the file (word and excel will open in the browser as long as they have the applications or viewers installed), or you can do some funky client side script that gets written to a label that performs a window.open, and you dynamically put the file name in there.

hth

D'Arcy
 

Thank you, yes, that helped tremendously. Such a simple thing, just needed someone to point me in the right direction.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top