LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default VB Excel Problem

"Robert Lie" wrote in message
oups.com...
I run it from VB Form.

Dim xla As Excel.Application
Dim xlb As Excel.Workbook
Dim xls As Excel.Worksheet
Dim xlr As Excel.Range


Actualy, the main problem is how to remove the excel application from
Processes (Windows task manager) after the excel is closed?


Hi Robert,

As Tim has pointed out, your code is filled with unqualified references
to Excel properties and methods. Whenever you run something like this from
VB:

Set xlr = Range(xls.Cells(1, 1), xls.Cells(1, 3))

You haven't told VB what object the Range method applies to so VBA
creates a hidden instance of the default object for it. Then, when you try
to close Excel you can't, because your VB application still has all of these
hidden references to Excel that you have no way to get rid of.

In the case above, all you need to do to correct the problem is this:

Set xlr = xls.Range(xls.Cells(1, 1), xls.Cells(1, 3))

This makes every Excel method in that line of code fully qualified and
therefore doesn't create any additional references to Excel. You need to do
the same thing for all the rest of your code.

Every reference to every Excel object, property and method in your
program must derive in an unbroken sequence from your original Excel
Application object variable. Once you do this you will be able to destroy
all the Excel references your program creates and shut Excel down cleanly.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


 
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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Problem viewing Excel 2003 Pivot Chart fields in Excel 2007 ronny B Charts and Charting in Excel 1 October 24th 08 10:08 PM
Weird problem with Excel 2000...Worksheets disappearing in a shared Excel file BrianL_SF Excel Discussion (Misc queries) 2 October 10th 06 08:27 PM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
EXCEL FORMAT PROBLEM WHEN SENDING EXCEL SHEET AS MESSAGE BODY IN . P.S.Sodha Excel Discussion (Misc queries) 0 April 2nd 05 01:53 PM


All times are GMT +1. The time now is 07:29 PM.

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

About Us

"It's about Microsoft Excel"