I am attempting to manipulate an existing excel pivot table using vbscript. I want to group the pivot table by 7 day weeks. I can sucessfully group by months but when I try to group by days I get a type mismatch error.
The script I am using is below:
myArray = Array(FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,FALSE)
Set objXL = WScript.CreateObject("Excel.Application"
objXL.Visible = FALSE
objXL.DisplayAlerts = FALSE
objXL.Workbooks.Open("c:\temp\weekly.xls"
Set objSheet = objXL.ActiveWorkBook.Sheets.Item(1)
Set objPivot = objSheet.PivotTables(1)
Set groupRange = objPivot.PivotFields("DataDate".DataRange
' groups by months sucessfully
' groupRange.Cells(1).Group
' group by weeks fails with a type mismatch error
groupRange.Cells(1).Group by=7, periods=MyArray
objXL.ActiveWorkBook.Save()
objXL.Quit()
Thank you in advance
The script I am using is below:
myArray = Array(FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,FALSE)
Set objXL = WScript.CreateObject("Excel.Application"
objXL.Visible = FALSE
objXL.DisplayAlerts = FALSE
objXL.Workbooks.Open("c:\temp\weekly.xls"
Set objSheet = objXL.ActiveWorkBook.Sheets.Item(1)
Set objPivot = objSheet.PivotTables(1)
Set groupRange = objPivot.PivotFields("DataDate".DataRange
' groups by months sucessfully
' groupRange.Cells(1).Group
' group by weeks fails with a type mismatch error
groupRange.Cells(1).Group by=7, periods=MyArray
objXL.ActiveWorkBook.Save()
objXL.Quit()
Thank you in advance