How to Kill Excel application process

G

Guest

I porgramming under Visual Basic 6 and Visual Studio .NET 2003, using Win XP.
I have a next problem. After i close my soft., then i cannot run excel
corretly - the center part of the excel is not visible. A create a code like
this:

1. Create a reference
2. Inicialize excel app from visual basic:
Dim ExcelApp As New Excel.Application
Dim ExcelWB As Excel.Workbook = ExcelApp.Workbooks.Add
Dim ESheet As Excel.Worksheet = ExcelWB.Worksheets(1)

3. Do with ESheet what i need
4. Try to kill excel application:
ExcelWB.Close()
ExcelApp.Quit()

ESheet = Nothing
ExcelWB = Nothing
ExcelApp = Nothing

But if i after this run excel with directly clicking on excel sheet on
desktop, the excel don't run correctly.

Thank you for your help, and sorry my english.
 
N

NickHK

HoGo,
If this is VB6, you will not be able to compile in the first place as:
Dim ExcelWB As Excel.Workbook = ExcelApp.Workbooks.Add
is not valid.
You need:
Dim ExcelWB As Excel.Workbook
Set ExcelWB = ExcelApp.Workbooks.Add

If this is not VB6, I can't help you much.

NickHk
 
H

Harald Staff

Hi

Put
ExcelApp.Visible = True
early on for testing purposes. Because Excel may ask you things, like "save
changes ?" and if you don't see or reply then she won't close properly.
Which would be a problem at least here:
ExcelWB.Close()
ExcelApp.Quit()

Please clarify "excel don't run correctly"

HTH. Best wishes Harald
 

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

Top