Advertisement

07.23.2008 at 12:45AM PDT, ID: 23587621
[x]
Attachment Details

Public member 'xlPivotTableSourceType' on type 'ApplicationClass' not found

Asked by borgb002 in Microsoft Excel Spreadsheet Software, Microsoft Visual Basic.Net

Tags: MICROSOFT, Excel, 2003

I'm totally new to creating PivotTables into Excel from VB .NET and I'm receiving this error:
Public member 'xlPivotTableSourceType' on type 'ApplicationClass' not found.  This happens when the following line of code is encountered:
                 
                Dim ptCache As Excel.PivotCache = wb.PivotCaches.Add(SourceType:=excel.XlPivotTableSourceType.xlExternal)



 Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
Dim excel As Microsoft.Office.Interop.Excel.Application
            Dim wb As Microsoft.Office.Interop.Excel.Workbook
            Dim ws As Microsoft.Office.Interop.Excel.Worksheet
            Dim rng As Microsoft.Office.Interop.Excel.Range
 
            excel = New Microsoft.Office.Interop.Excel.Application
            wb = excel.Workbooks.Open(FileToLoad)
            ws = wb.Sheets("Sheet1")
            excel.Visible = True
            wb.Activate()
            
 
Try
 
                Dim xlRange As Excel.Range = DirectCast(ws, Excel.Worksheet).Range("1:65536")
 
                'Create the Pivotcache.
                Dim ptCache As Excel.PivotCache = wb.PivotCaches.Add(SourceType:=excel.XlPivotTableSourceType.xlExternal)
 
                'Create the Pivottable.
                Dim ptTable As Excel.PivotTable = ws.PivotTables.Add(PivotCache:=ptCache, _
                        TableDestination:=xlRange, TableName:="PT_Report")
 
 
 
                'Setup the Pivottable.
                With ptTable
                    .ManualUpdate = True
                    .PivotFields("POS").Orientation = excel.XlPivotFieldOrientation.xlRowField
                    .PivotFields("SKU").Orientation = excel.XlPivotFieldOrientation.xlDataField()
                    .PivotFields("LINE_OVERALL_DISCOUNT").Orientation = excel.XlPivotFieldOrientation.xlDataField()
                    .Format(excel.XlPivotFormatType.xlReport2)
                    .ManualUpdate = False
                End With
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
[+][-]07.23.2008 at 04:32PM PDT, ID: 22074904

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Excel Spreadsheet Software, Microsoft Visual Basic.Net
Tags: MICROSOFT, Excel, 2003
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628