B
BB programmer
Hello,
I'm using EXCEL 2002. I want to make a pivot table (report). I use Excel
record macro function to generate the following code :
(notice that some text can't be read because I'm using chinese windows,
excel will use chinese characters which creating table name)
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet2!C5:C12").CreatePivotTable TableDestination:= _
"[Schedule_report.xls]Sheet1!R4C3", TableName:="˜ü~·ÖÎö±Ã2",
DefaultVersion:= _
xlPivotTableVersion10
With ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").PivotFields("PLANT")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").PivotFields("STORAGE_LOC")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").PivotFields("GROUP_DELV_DATE")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").AddDataField
ActiveSheet.PivotTables
("˜ü~·ÖÎö±Ã2" _
).PivotFields("PO_KEY"), "Ó‹â€Âµ µÄPO_KEY", xlCount
When I try to execute this piece of code, there is run-time error 1004
"unable to get pivot fields property of the pivlot table class" displayed.
All the fields "PLANT",
"STORAGE_LOC", "GROUP_DELV_DATE" exist in sheet2, column 5 - 12.
What is the problem ?
thanks
I'm using EXCEL 2002. I want to make a pivot table (report). I use Excel
record macro function to generate the following code :
(notice that some text can't be read because I'm using chinese windows,
excel will use chinese characters which creating table name)
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet2!C5:C12").CreatePivotTable TableDestination:= _
"[Schedule_report.xls]Sheet1!R4C3", TableName:="˜ü~·ÖÎö±Ã2",
DefaultVersion:= _
xlPivotTableVersion10
With ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").PivotFields("PLANT")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").PivotFields("STORAGE_LOC")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").PivotFields("GROUP_DELV_DATE")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("˜ü~·ÖÎö±Ã2").AddDataField
ActiveSheet.PivotTables
("˜ü~·ÖÎö±Ã2" _
).PivotFields("PO_KEY"), "Ó‹â€Âµ µÄPO_KEY", xlCount
When I try to execute this piece of code, there is run-time error 1004
"unable to get pivot fields property of the pivlot table class" displayed.
All the fields "PLANT",
"STORAGE_LOC", "GROUP_DELV_DATE" exist in sheet2, column 5 - 12.
What is the problem ?
thanks