I run an Excel data capture macro from an external source (cube) via a VB script. The script creates an instance of Excel opens PERSONAL.XLS and runs a macro from this file. All is nice but macro halts and generates a run time error '-2147417848(80010108)' Method 'CreatePivotTable' of object 'PivotCache' failed at the respective line of code from the following block:
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"OLEDB;Provider=MSOLAP.2;Data Source=as3;Initial Catalog=IVR;Client Cache Size=25;Auto Synch Period=10000"
.CommandType = xlCmdCube
.CommandText = Array("Sales_Revenue")
.MaintainConnection = True
.CreatePivotTable TableDestination:="[" & strWkName & "]Sheet1!R3C1", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
End With
But when enter the debug mode and hit F8 pivot table is created and can continue macro successfully. What is causing the generated error for the initial run and how can I avoid it to allow automated script to run?
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"OLEDB;Provider=MSOLAP.2;Data Source=as3;Initial Catalog=IVR;Client Cache Size=25;Auto Synch Period=10000"
.CommandType = xlCmdCube
.CommandText = Array("Sales_Revenue")
.MaintainConnection = True
.CreatePivotTable TableDestination:="[" & strWkName & "]Sheet1!R3C1", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
End With
But when enter the debug mode and hit F8 pivot table is created and can continue macro successfully. What is causing the generated error for the initial run and how can I avoid it to allow automated script to run?