pivotable table example not working

Add-in Express™ Support Service
That's what is more important than anything else

pivotable table example not working
 
Subscribe
Prakash Bhandary




Posts: 4
Joined: 2026-07-30
Detailed technical information follows:
---
(Inner Exception)
Date and Time: 08-08-2026 12:56:03
Machine Name: DESKTOP-PFEJ07S
IP Address: fe80::5d5c:862a:47ec:5c48%20
Current User: DESKTOP-PFEJ07S\LENOVO

Application Domain: D:\addins\pivottables-slicers\PivotsAndSlicersDemo\PivotsAndSlicersDemo\bin\Debug\
Assembly Codebase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Assembly Full Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version: 4.0.0.0

Exception Source:
Exception Type: System.ArgumentException
Exception Message: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Exception Target Site: ForwardCallToInvokeMember

---- Stack Trace ----
System.RuntimeType.ForwardCallToInvokeMember(memberName As String, flags As BindingFlags, target As Object, aWrapperTypes As Int32[], msgData As MessageData&)
mscorlib.dll: N 0193 (0xC1) IL
Microsoft.Office.Interop.Excel.PivotCache.CreatePivotTable(TableDestination As Object, TableName As Object, ReadData As Object, DefaultVersion As Object)
mscorlib.dll: N 00000 (0x0) JIT
PivotsAndSlicersDemo.AddinModule.createPivotRibbonButton_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean)
AddinModule.cs: line 0237, col 17, IL 0140 (0x8C)
AddinExpress.MSO.ADXRibbonButton.DoInternalAction(e As ADXRibbonOnActionEventArgs)
mscorlib.dll: N 0035 (0x23) IL



(Outer Exception)
Date and Time: 08-08-2026 12:56:03
Machine Name: DESKTOP-PFEJ07S
IP Address: fe80::5d5c:862a:47ec:5c48%20
Current User: DESKTOP-PFEJ07S\LENOVO

Application Domain: D:\addins\pivottables-slicers\PivotsAndSlicersDemo\PivotsAndSlicersDemo\bin\Debug\
Assembly Codebase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/AddinExpress.MSO.2005/v4.0_10.4.4741.0__4416dd98f0861965/AddinExpress.MSO.2005.dll
Assembly Full Name: AddinExpress.MSO.2005, Version=10.4.4741.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 10.4.4741.0

Exception Source:
Exception Type: AddinExpress.MSO.ADXExternalException
Exception Message: An error has occurred in the code of the add-in.

---- Stack Trace ----

Getting following error message
Posted 08 Aug, 2026 07:33:27 Top
Andrei Smolin


Add-in Express team


Posts: 19232
Joined: 2006-05-11
Hello Prakash,

In the method replace the beginning of the first try block with the following code:

            try
            {
                activeWorkBook = ExcelApp.ActiveWorkbook;
                pivotWorkSheet = (Excel.Worksheet)ExcelApp.Sheets.Add();
                pivotWorkSheet.Activate();

                // Create the Pivot Table
                pivotCaches = activeWorkBook.PivotCaches();
                pivotCache = pivotCaches.Create(Excel.XlPivotTableSourceType.xlDatabase, "Sheet1!$A$1:$D$31");
                pivotTable = pivotCache.CreatePivotTable(pivotWorkSheet.Name + "!R3C1");


Does it work?

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Aug, 2026 08:49:28 Top