Open Excel File

T

tianung

I have the following vbscript (living on my PC desktop) that I use to
open an Excel file stored on the web:

Dim xlApp
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
On Error Resume Next
Set oWorkbook = xlApp.Workbooks.Open("http://xxxxx.com/
myworkbook.xls")
If Err.Number <> 0 Then
WScript.Quit
End If
xlApp.Visible = True
oWorkbook.Activate

I would like to put this vbscript on the web so other people can use
it. Ideally, I want to give them an "http://...." address that they
can navigate to, and when they do, the vbscript living in this http
location would automatically activate and open the Excel file on their
local PC's (in Excel itself and not embedded in IE). I have little
experience with ASP and HTML (but know a fair bit of Excel VBA), and
would appreciate the complete HTML / ASP code that would incorporate
the above vbscript to achieve this purpose.

Thanks for your help.

AP
 
A

Adrienne Boswell

Gazing into my crystal ball I observed tianung <[email protected]>
writing in @o18g2000pra.googlegroups.com:
I have the following vbscript (living on my PC desktop) that I use to
open an Excel file stored on the web:

Dim xlApp
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
On Error Resume Next
Set oWorkbook = xlApp.Workbooks.Open("http://xxxxx.com/
myworkbook.xls")
If Err.Number <> 0 Then
WScript.Quit
End If
xlApp.Visible = True
oWorkbook.Activate

I would like to put this vbscript on the web so other people can use
it. Ideally, I want to give them an "http://...." address that they
can navigate to, and when they do, the vbscript living in this http
location would automatically activate and open the Excel file on their
local PC's (in Excel itself and not embedded in IE). I have little
experience with ASP and HTML (but know a fair bit of Excel VBA), and
would appreciate the complete HTML / ASP code that would incorporate
the above vbscript to achieve this purpose.

Thanks for your help.

AP

You need to set the application type in the header. Make sure you put
this BEFORE anything else.

response.contenttype = "application/vnd.ms-excel"
'rest of your script

Now, as to how the file opens is up to the user. If the user has
explicitly set excel files to open in the browser, then they will.
There is nothing you can do about that. What I would suggest, however,
is warn the user first that it's an excel file, something like:

<a href="myexcelfile.asp" type="application/vnd.ms-excel" title="Excel
spreadsheet">Download Excel spreadsheet</a>
 
T

tianung

You need to set the application type in the header.  Make sure you put
this BEFORE anything else.

response.contenttype = "application/vnd.ms-excel"
'rest of your script

Thanks Adrienne. When I said I have limited experience, I mean I've
never written a single html/asp script before ! :) Do I simply
write this and save as <some filename>.html at the "http:// ..."
location ? (Please bear with my total ignorance)

------

<html>
<body>

<%
response.contenttype = "application/vnd.ms-excel"
Dim xlApp
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
On Error Resume Next
Set oWorkbook = xlApp.Workbooks.Open("http://xxxxx.com/
myworkbook.xls")
If Err.Number <> 0 Then
WScript.Quit
End If
xlApp.Visible = True
oWorkbook.Activate
%>

</body>
</html>
 

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

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top