Excel ASP Save

  • Thread starter Thread starter yosh o
  • Start date Start date
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
 
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
 
Back
Top