View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Instance still there in task manager after xlapp.Application.Quit

Mo,

I was trying to make my way thru your code and got confused.
Why are you opening a new instance of Excel?
It appears you already have Excel open and if so, you can open additional
workbooks in the same instance.
Also, it appears as if you add a new sheet (sheetcount +1), paste in to it
and then delete it?
Could you provide a narrative of what you want to do?

Regards,
Jim Cone
San Francisco, USA


"Mo"
wrote...
Hi Guys,
I have read a lot of posts but I still can not make it work on Excel
2002.
My Code

Sub Get_Report_Data_Closed()

Dim FileName As Variant
Dim extractsize As Integer

FileName = Application.GetOpenFilename _
(filefilter:="Excel Wookbook(*.xls),*.txt,All Files(*.*),*.*")
If FileName = False Then
MsgBox "You did not select a file."
Sheets("SetupSummary").Select
Exit Sub
End If
Application.ScreenUpdating = False
Sheets("ClosedTicketReport").Select
Range("A:Z").Select
Selection.ClearContents
Set xlapp = New Excel.Application
Set xlbook = xlapp.Workbooks.Open(FileName, False, True)
Set xlSheet = xlbook.Worksheets(1)
sheetcount = ThisWorkbook.Sheets.Count
ThisWorkbook.Sheets.Add After:=Worksheets(sheetcount)
xlSheet.UsedRange.Copy
ThisWorkbook.Sheets(sheetcount + 1).Paste
Selection.Copy
Sheets("ClosedTicketReport").Select
Range("A1").Select
ActiveSheet.Paste
Columns("A:Z").EntireColumn.AutoFit
Application.DisplayAlerts = False
Worksheets(sheetcount + 1).Delete
Application.DisplayAlerts = True

'The following code is problemetic
xlapp.ActiveWorkbook.Close
Set xlbook = Nothing
xlapp.Application.Quit
Set xlapp = Nothing
End Sub

Can someone please help me. This code works on my Excel 2003 at home
but not at work where I have Excel 2002.
Thanks a lot in advance.