View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Keith Willshaw Keith Willshaw is offline
external usenet poster
 
Posts: 170
Default Error about ExcelApp.Workbooks.Add


"YaYa" wrote in message
...
Hello, It still has the problem.

When I open this created Excel file, then:
If I press right-up corner inner X button(This Excel File) === has a
problem.


What is the problem ?

If I press File - Digest Information === has a problem.


What is the problem ?


If I press right-up corner outer X button(Excel Application) === No
problem.
If I press File - Close File === No problem.
If I press File - Exit === No problem.
(P.S.: Running this web page and opening this Excel file are on the same
computer.)

If opening this Excel file on other computer, it doesn't have any

problems.

How to solve it?
Thanks.

This is the code(web page):
It runs on .Net Framework 1.1.
--------------------------------------------------------------------------

--
-
<%@ Page Language="vb" debug="true" %
<%@ import Namespace="Excel" %
<html
<body
<%
Dim xlApp As Excel.Application
xlApp = New Excel.Application()

Dim xlWk As Excel.Workbook
Dim xlRg As Excel.Range

Try
xlWk = xlApp.Workbooks.Add()

xlRg = xlWk.Worksheets(1).Range("A1")
xlRg.Value = "whatever data I want"

Dim blah as String
blah = "C:\Inetpub\temp\Books.xls"
xlWk.SaveAs(blah)

xlWk.Close()
Catch e As System.Runtime.InteropServices.COMException
Response.Write(e)
End Try

xlApp.Workbooks.Close()


I suggest replacing this with a statement explicitly
closing the workbook yo manipulated

xlWk.Close

Keith