Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Error about ExcelApp.Workbooks.Add

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.
If I press File - Digest Information === has a 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()
xlApp.DisplayAlerts=False
xlApp.Quit()
xlRg = Nothing
xlWk = Nothing
xlApp = Nothing
%
</body
</html
----------------------------------------------------------------------------
-



"Keith Willshaw" ¼¶¼g©ó¶l¥ó·s»D
...

"YaYa" wrote in message
...
Thanks.

It can create a Excel file now.

But, if I open this created Excel file, then close this Excel file,
System will show a window:
Microsoft Excel occurs problems, it must be closed, sorry.
It has three buttons: Debug, Reply this problem, and Not reply.
(P.S.: This is I translate strings from Chinese words.)

Do you have this problem?
And Why? How to solve?

Thanks.


You need to release all objects and close the Excel instance
before ending

Typically

xlApp.DisplayAlerts=False
xlApp.Quit

Set xlWk=Nothing
Set xlApp=Nothing

Keith




  #2   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy between workbooks error Mike Fitz Excel Discussion (Misc queries) 2 July 24th 07 09:22 PM
Countif error using multiple workbooks Melody4572 Excel Discussion (Misc queries) 11 February 6th 07 01:19 PM
Linking between workbooks and getting #REF error TangentMemory Excel Discussion (Misc queries) 0 November 10th 05 12:34 AM
#Value error when linking workbooks FOLALD Excel Worksheet Functions 1 September 13th 05 02:17 AM
add-ins error + setting workbooks peach255 Excel Programming 0 July 21st 03 07:28 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"