Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Excel Object (PLEASE)

Status
Not open for further replies.

Ferlin

Programmer
Jan 18, 2001
71
US
Hello All,

I recently wrote an application that exports several ASCII files into an Excel Workbook. The application after it has finished it's exporting terminates and Excel loads up and shows the Workbook with several WorkSheets in it.

I just noticed that if I have run the export program 3 times today, then look in the Task Manager, Excel.exe will show up 3 times in the list. How do I STOP that from happening? I exit Excel after saving my Workbook.

Here is how I use the object in my export class.

In the declaration section I have this line:

Dim objExcel As Excel.Application

In the Class_Initialize routine is these lines:

Set objExcel = New Excel.Application
objExcel.Visible = False

In the Class_Terminate routine is these lines:

objExcel.Visible = True
Set objExcel = Nothing

ANY HELP would be greatly appreciated.

Thanks In Advance.

Ferlin
 
I have just from reading other helps on this as there is a long thread here about it think they came up with
setting the book, the sheet and the application to nothing as well as the application .quit :

Set objResultsSheet = Nothing
Set objXLBook = Nothing
Set objXLApp = Nothing
objXLApp.Quit

as ending the application of Excel so there is not more than one running. If you do a search they also have information about checking to see if instances of excel are already running and not opening a new one before creating the workbook.

'Start Excel if not running.
' ---------------------------------------------------
bWasntRunning = False
'Try first to use an existing instance.
Set Excel = GetObject(, "Excel.Application")
If Err Then
Err.Clear
'Excel isn't running, so start it.
bWasntRunning = True
Set Excel = CreateObject("Excel.Application")
If Err <> 0 Then
MsgBox (&quot;Could Not Load Excel!&quot;), vbExclamation
End
End If
End If
On Error GoTo 0

Hope that helped.

Joanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top