Home All Groups Group Topic Archive Search About
Author
4 Jul 2009 4:11 PM
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

Author
4 Jul 2009 6:52 PM
Adrienne Boswell
Gazing into my crystal ball I observed tianung <tian***@hotmail.com>
writing in news:fbe5115f-bc45-40b0-9ad0-728492de0a78
@o18g2000pra.googlegroups.com:

Show quoteHide quote
> 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>
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Are all your drivers up to date? click for free checkup

Author
5 Jul 2009 12:54 AM
tianung
On Jul 5, 6:52 am, Adrienne Boswell <arb***@yahoo.com> wrote:
>
> 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>

Bookmark and Share