dbTalk Databases Forums  

Excel Doesn't Close With Pivot Table Automation

comp.database.ms-access comp.database.ms-access


Discuss Excel Doesn't Close With Pivot Table Automation in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jason
 
Posts: n/a

Default Excel Doesn't Close With Pivot Table Automation - 07-03-2003 , 04:57 PM






Here it is again. I've run into this problem before, but my usual
solutions aren't working. When the code closes Excel, it remains in
the processes list. Can anybody help me figure our why the code below
doesn't close Excel properly? Excel closes fine if I take out the
Pivot table code, so the problem is there.

Thanks in advance!

Jason

--------
Dim objXL, objActiveWkb As Object

Set objXL = CreateObject("Excel.Application")

objXL.Application.Visible = True
objXL.Application.Workbooks.Add

'Create Pivot With Data Already In Excel

objXL.Application.ActiveWorkbook.PivotCaches.Add(S ourceType:=xlDatabase,
_ SourceData:= "'Sheet 2'!R1C1:R2C3").CreatePivotTable _
TableDestination:=Range("A1"),TableName:="PivotTab le1"

objXL.Application.ActiveSheet.PivotTables("PivotTa ble1").ColumnGrand =
False
objXL.Application.ActiveSheet.PivotTables("PivotTa ble1").RowGrand =
False
objXL.Application.ActiveSheet.PivotTables("PivotTa ble1").SmallGrid =
False

objXL.Application.ActiveSheet.PivotTables("PivotTa ble1").AddFields _
RowFields:="Data", ColumnFields:="Year"

objXL.Application.ActiveSheet.PivotTables("PivotTa ble1").PivotFields _
("PLTHT_in").Orientation = xlDataField

objXL.Application.ActiveSheet.PivotTables("PivotTa ble1").PivotFields _
("EARHT_in").Orientation = xlDataField

'Save and Close
objXL.Application.ActiveWorkbook.SaveAs "C:\test.xls"
objXL.Application.ActiveWorkbook.Close
objXL.Application.Quit
Set objXL = Nothing

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.