Hey guys,
I got a question about Excel COM.
I'm using it to import data from Excel, so it requires that I start, in the
background, instances of the application itself.
Dim app As New Excel.Application
app.Workbooks.Open(iPath)
app.Workbooks(1).Worksheets(2).Copy()
app.DisplayAlerts = False
app.ActiveWorkbook.SaveAs(oPath,
FileFormat:=Excel.XlFileFormat.xlTextWindows)
app.Workbooks(1).Close(False)
app.Quit()
Do
If System.Runtime.InteropServices.Marshal.ReleaseComObject(app) = 0 Then
Exit Do
Loop
So after all this, I still see the Excel application residing in memory.
They will exit after I close down the VB program, sometimes. This is a
serious problem - can anyone tell me how I can reliably shut down the
application entirely after I use them? Thanks.
Steven
Woody - 30 Jul 2003 06:28 GMT
'used to generate the document check list for the applicants
Dim exlApp As Excel.Application
Dim exlBook As Excel.Workbook
dim newdocname as string
'----------------------------------------------------------
' Get Excel if it's running
Set exlApp = GetObject(, "Excel.Application")
If Err <> 0 Then
'Excel wasn't running, start it from code
Set exlApp = CreateObject("Excel.Application")
End If
' remove old filem create new excel spreadsheet
Kill App.Path & "/" & newDocName & ".xls"
Set exlBook = Workbooks.Add
With exlBook
.Title = newDocName
.Subject = "compute this"
.SaveAs FileName:=App.Path & "/" & newDocName & ".xls"
End With
' make it active
Workbooks(newDocName & ".xls").Activate
' only need first sheet so activate it and hide the other 2
With ActiveWorkbook
Sheets(3).Visible = False
Sheets(2).Visible = False
Sheets(1).Activate
End With
With ActiveSheet
.PageSetup.LeftHeader = "&D"
.PageSetup.CenterHeader = "&B" & newDocName
.PageSetup.RightHeader = "data Header"
.PageSetup.LeftFooter = "&P of &N"
.PageSetup.CenterFooter = "American Jobs LLC"
.PageSetup.RightFooter = "&B Company Confidential Information"
.PageSetup.Orientation = xlLandscape
End With
' save spreadsheet, close it, end Excel
exlBook.Save
exlBook.Close
exlApp.Quit
'release excel resources
Set exlBook = Nothing
Set exlApp = Nothing
this works for me but that isnt a garauntee it will for you.
Woody
I am not responsible for anything you may see with my name attached to
it, i think.