+ Reply to Thread
Results 1 to 5 of 5

Error "Unable to set the Visible property of the PivotItem class"

  1. #1
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Error "Unable to set the Visible property of the PivotItem class"

    Dear All,

    Here's another headscratcher for all of you experts!

    I have searched the Internet for a solution to this problem but, although many people appear to have encountered problems similar to mine, I have been unable to find an approach which works.

    My worksheet contains just a single (but large!) pivot table, and I wish to manipulate various pivot items in various pivot fields.

    The following code does not do anything particularly useful (it's used just for debugging!), but the point is that it works perfectly for pivot fields (e.g. "Task Name") which do not contain dates, whereas problems arise when processing a pivot item in a date-related pivot field (e.g. "Billing Doc Date").


    Please Login or Register  to view this content.


    It is probably worth noting that the "faulty" (i.e. date-related) pivot item DOES exist, as it is possible to create an object reference to it, and many of the properties of this object are correctly exposed, but with the noticeable exception of the "Visible" property!!! - i.e. the first MsgBox statement displays the information required, whereas the second MsgBox statement produces the "Type Mismatch" error message.

    Also, no AutoSort has been applied to the above pivot fields. The "Task Name" pivot field contains 970 pivot items, and the "Billing Doc Date" pivot field contains 400 pivot items.


    In summary:
    (a) in the case of the "Task Name" pivot field, all of the above code works correctly;
    (b) in the case of the "Billing Doc Date" pivot field:
    (1) the first MsgBox statement works correctly;
    (2) the line "MsgBox pvtItem.Visible" produces the "Type Mismatch" error message;
    (3) commenting-out the above line allows the line "pvtItem.Visible = False" to be executed and thereby produce the "Unable to set the Visible property of the PivotItem class" error message.


    Any information or suggestions regarding the above would be much appreciated.

    Best regards,

    Greg M
    Last edited by Greg M; 12-04-2010 at 04:55 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Error "Unable to set the Visible property of the PivotItem class"

    A sample file would help here.

    I know from prior threads that Pivot Dates are handled differently between versions in terms of assumed formatting on part of VBA, however, without data / source info. (external etc...) / version info. it's hard to offer anything useful.
    Last edited by DonkeyOte; 12-04-2010 at 04:16 PM. Reason: typo

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error "Unable to set the Visible property of the PivotItem class"

    Hi there,

    Many thanks for your reply.

    Sorry, I forgot to mention that I'm using Excel 2010.

    The workbook involved is large and its contents are commercially-sensitive, so I'm unable to post it here. Also, the workbook I receive contains only the pivot table itself - I don't have access to the source data file, so I'm unable to post even a sample from it.

    The pivot table contains 33 pivot fields, four of which are dates, and the problem is consistent - i.e. it occurs on all date-related pivot fields, but not on string or arithmetic pivot fields.

    Referring to my original post, the fact that the first MsgBox statement operates correctly confirms that the "faulty" (i.e. date-related) pivot item objects DO exist, and CAN be referenced.

    The puzzling thing about these pivot item objects is that:
    (a) their Visible property DOES exist (i.e. there is no "Object doesn't support this property or method" error message);

    (b) the "Type Mismatch" error message suggests that their Visible property seems to have a non-Boolean value;

    (c) their Visible property cannot be set - possibly because of (b).

    Any further comments/suggestions?

    Thanks again for taking the trouble to reply.

    Greg M

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Error "Unable to set the Visible property of the PivotItem class"

    Try adding:

    Please Login or Register  to view this content.
    prior to first Set line (it may seem odd but it's a probable fix see this old thread for a similar issue)

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Error "Unable to set the Visible property of the PivotItem class"

    Hi again, Man of La Mancha,

    Many thanks for your suggestion - I inserted that code as you proposed and the routine now works for date-related pivot fields also. Just what I wanted!

    I'm sure Microsoft have a perfectly logical explanation for why the Visible property somehow changed from Boolean to non-Boolean but, in its absence, I'm just glad you were around to help out!

    Thanks again, and best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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