How to save an excel workbook in a web application

G

Guest

I used the following code to create a workbook and save it in a
webapplication.

dim oExcel As Excel.ApplicationClass
dim oBook As Excel.WorkbookClass
dim obooks As Excel.Workbooks
dim designb As Excel.Workbook
dim osheets As Excel.Sheets

dim result as string
result = "c:\result.xls"
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
obooks = oExcel.Workbooks
designb = obooks.Open(result)
osheets = designb.Worksheets

.........

designb.save

However, it seems it takes forever to save it.

I tried another method as following, but with the same result.

designb.Close(savechanges:=True)

When I used designb.saveas(path), path is a new directory, it works
fine. I needs to save the file to the same location. Please let me know
what I need to do. Thanks a lot.
 
J

John Armenia

Part of it could be related to the fact your using a mixture of early and
late binding to excel. I would suggest using stritly early binding as that
is much faster. Here is how I would do it.

'this is late binding I wouldn't do it this way
oExcel = CreateObject("Excel.Application")

'instead use the new fucntion of the Excel.Application
oExcel = New Excel.Application

Everything else should be the same. Try that and see if it runs any faster.

John
 
G

Guest

I used the following code to create a workbook and save it in a
webapplication.

dim oExcel As Excel.ApplicationClass
dim oBook As Excel.WorkbookClass
dim obooks As Excel.Workbooks
dim designb As Excel.Workbook
dim osheets As Excel.Sheets

dim result as string
result = "c:\result.xls"
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
obooks = oExcel.Workbooks
designb = obooks.Open(result)
osheets = designb.Worksheets

.........

designb.save

However, it seems it takes forever to save it.

I tried another method as following, but with the same result.

designb.Close(savechanges:=True)

When I used designb.saveas(path), path is a new directory, it works
fine. I needs to save the file to the same location. Please let me know
what I need to do. Thanks a lot.

User submitted from AEWNET (http://www.aewnet.com/)
 

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

Similar Threads


Top