Closing Excel From VB
Hi guys
I am having problem in closing the excel application from my COM Component I have following code in one of my COM method and when the method finishes, I still see Excel application running in task ba can anyone help me? please can you tell me what i am doing wrong? Thanks in advanc Dim appXl As Excel.Applicatio Dim oWorkBook As Excel.Workboo Dim qTable As Excel.QueryTabl Set appXl = CreateObject("Excel.Application" appXl.Workbooks.Open "someifle.xls '' import the text fil Set qTable = appXl.ActiveSheet.QueryTables.Add(Connection:= "TEXT;" & strCSVFileName, Destination:=Range("A1") For Each oWorkBook In appXl.Workbook oWorkBook.Close SaveChanges:=Tru oWorkBook.Application.Qui Nex Set qTable = Nothin appXl.Qui Set oWorkBook = Nothin Set appXl = Nothing |
Closing Excel From VB
Sorry Guys
the following statment is not there i just added to varify it works or not It doesnt work oWorkBook.Application.Qui |
Closing Excel From VB
reverse the lines:
set oWorkbook = nothing xlApp.Quit keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "?B?Tml0aW4=?=" wrote: Sorry Guys the following statment is not there i just added to varify it works or not It doesnt work oWorkBook.Application.Quit |
Closing Excel From VB
Hi I tried it but didn work here is the new code Dim appXl As Excel.Application Dim oWorkBook As Excel.Workbook Dim qTable As Excel.QueryTable Set appXl = CreateObject("Excel.Application") appXl.Workbooks.Open somfile.xls appXl.Worksheets("Data").Activate appXl.ActiveSheet.UsedRange.Clear Set qTable = appXl.ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;" & strCSVFileName, Destination:=Range("A1")) Set qTable = Nothing appXl.Worksheets("Report").Activate appXl.ActiveSheet.PivotTables("PivotTable1").Pivot Select "", xlDataAndLabel, True For Each oWorkBook In appXl.Workbooks oWorkBook.Close SaveChanges:=True Next Set oWorkBook = Nothing appXl.Quit Set appXl = Nothing *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Closing Excel From VB
Hi
I tried it but didnt work here is new code Dim appXl As Excel.Applicatio Dim oWorkBook As Excel.Workboo Dim qTable As Excel.QueryTabl Set appXl = CreateObject("Excel.Application" appXl.Workbooks.Open somfile.xl appXl.Worksheets("Data").Activat appXl.ActiveSheet.UsedRange.Clea Set qTable = appXl.ActiveSheet.QueryTables.Add(Connection:= "TEXT;" & strCSVFileName, Destination:=Range("A1") Set qTable = Nothin appXl.Worksheets("Report").Activat appXl.ActiveSheet.PivotTables("PivotTable1").Pivot Select "", xlDataAndLabel, Tru For Each oWorkBook In appXl.Workbook oWorkBook.Close SaveChanges:=Tru Nex Set oWorkBook = Nothin appXl.Qui Set appXl = Nothing |
All times are GMT +1. The time now is 01:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com