Closing Excel
Closing Excel
Closing Excel
Closing Excel
Closing Excel
Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel
Closing Excel Closing Excel
Closing Excel
Go Back  Xtreme Visual Basic Talk > > > Closing Excel


Reply
 
Thread Tools Display Modes
  #21  
Old 05-02-2005, 11:07 AM
ychan ychan is offline
Newcomer
 
Join Date: May 2005
Posts: 1
Default


Hi,

Have you tried
objApp.Workbooks.Add(PgS.excelTemplate) instead of objApp.Workbooks.Open(PgS.excelTemplate)? I had a similar problem and I could not figure out why the Excel Object would not close. I Stumbled upon Mike_R's excellent tutorial on Automating Office Programs with VB.Net / COM Interop (Automating Office Programs with VB.Net / COM Interop) but when I replaced the
Dim oWB As Excel.Workbook = oApp.Workbooks.Add with
Dim oWB As Excel.Workbook = oApp.Workbooks.Open("E:\Excel Test database\janv2005.xls"), the Excel object is not released, but changing the code to
Dim oWB As Excel.Workbook = oApp.Workbooks.Add("E:\Excel Test database\janv2005.xls") works fine.

Not sure if this will work for you, but it's worth a try.

Yu-Lin
Reply With Quote
  #22  
Old 05-02-2005, 12:39 PM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Hi Yu-Lin,

Welcome to the Forum. (And thanks for the compliments )

We'll have to keep your advice in mind regarding Workbooks.Add() vs. Workbooks.Open(). I don't really see why .Open() would be a problem unless one forgot to call .Close() before attempting Application.Quit(), but every bit of information helps...

Also one has to keep in mind, of course, that using Workbooks.Add(Template:=""E:\Excel Test database\janv2005.xls") is not quite the same as Workbooks.Open(FileName:="E:\Excel Test database\janv2005.xls"), as using .Open() opens the Workbook with a reservation, while using .Add() is actually opening the Workbook as a copy of the original.

Also, the technique described by BellShapedHead in this thread has now been included in that tutorial itself, within Post #3 Closing your App -- Extreme Measures.

,
Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Closing Excel
Closing Excel
Closing Excel Closing Excel
Closing Excel
Closing Excel
Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel Closing Excel
Closing Excel
Closing Excel
 
Closing Excel
Closing Excel
 
-->