+ Reply to Thread
Results 1 to 2 of 2

Run-time Error '91':Object Variable or With block variable not set When Runing XLA Add-in

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    N. America
    MS-Off Ver
    Excel 2003
    Posts
    4

    Run-time Error '91':Object Variable or With block variable not set When Runing XLA Add-in

    I tested the same code below after recording the macro and it works.
    So, I saved it as an xla add-in and ran the same code. It creates the pivot table
    but I get the error below when it is about to fill the data for the row

    Run-time Error '91':Object Variable or With block variable not set

    This error on the procedure Sub Test() below occurs at line ActiveWorkbook.PivotTableWizard. How should I fix this?

    Sub Test()

    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "print_logs!R3C1:R6C40").CreatePivotTable TableDestination:="", TableName:= _
    "PivotTable1", DefaultVersion:=xlPivotTableVersion10

    ********* Error Message shows when executing line below

    ActiveWorkbook.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    ActiveSheet.Cells(3, 1).Select
    ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Comment", _
    ColumnFields:="Paper Size"
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Total Pages").Orientation _
    = xlDataField


    End Sub

  2. #2
    Registered User
    Join Date
    09-25-2012
    Location
    N. America
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Run-time Error '91':Object Variable or With block variable not set When Runing XLA Add

    change ActiveSheet to ActiveWorkbook.ActiveSheet

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1