Excel ASP Save


Y

yosh o

I hope this is the right area to post this, and I appoligize if it isn't
in advance.

I've spent the last few days trying to figure out what I'm doing wrong
in this code. What I'm doing is that I'm opening an excel file,
changing the header and then trying to save and close the file. Instead
when I run it, the web page hangs.

Sub Headers()
Dim xlapp ' Our Excel App
Dim wb ' Our Workbook within the Excel App
Dim ws ' Our Worksheet within the Workbook

Set xlapp = Server.CreateObject("Excel.Application")
Set wb = xlapp.Workbooks.open("\\server\path\test.xls")
Set ws = wb.Worksheets(1)

ws.pagesetup.LeftHeader="Some Text"

wb.Save()

Set wb = Nothing
xlapp.Quit
Set xlapp = Nothing
End Sub
 
Ad

Advertisements

A

Alvin Bruney [MVP - ASP.NET]

what is xlapp after the create call? are you testing for null? If you are,
then you need to check permissions to access the test.xls file.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 

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