+ Reply to Thread
Results 1 to 5 of 5

Refresh all pivot tables when emailed spreadsheet is opened

  1. #1
    Registered User
    Join Date
    11-30-2021
    Location
    Basingstoke, England
    MS-Off Ver
    Office 365
    Posts
    3

    Post Refresh all pivot tables when emailed spreadsheet is opened

    Hello

    I have an automated process that populates a spreadsheet and emails it. The spreadsheet contains pivot tables and the data for those tables is in the spreadsheet and gets updated by my process before the email. My process cannot update the pivot tables before sending the spreadsheet so I added a button that the recipients can click to refresh them. What I would like to do is remove this user step and just make the spreadsheet update automatically on opening. So I added this macro to do that.

    Please Login or Register  to view this content.
    This works for my copy when I open it from my folder, however when the spreadsheet is emailed and I open it, it is in protected view and when I enable editing the macro fails with an error "Object variable or with block variable not set", which I assume is because the macro ran when the spreadsheet was in protected mode.

    Does anyone know a way to auto-refresh pivot tables when the user opens their emailed copy?

    I'm on the 365 version of excel using windows 10.

    Thanks.
    Last edited by AliGW; 01-10-2022 at 05:37 AM. Reason: Code tags added.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,398

    Re: Refresh all pivot tables when emailed spreadsheet is opened

    Administrative Note:

    Welcome to the forum.

    You need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    11-30-2021
    Location
    Basingstoke, England
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Refresh all pivot tables when emailed spreadsheet is opened

    Thank you. I will remember for next time!

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,204

    Re: Refresh all pivot tables when emailed spreadsheet is opened

    This is a known issue when the workbook was opened in Protected View (version 2013 or later). In the Workbook_Open procedure does not recognize application objects, properties, and methods. But they are already visible in Workbook_Activate. This only happens once when we first run a file downloaded from a website or email. After agreeing to edit the file, the problem disappears when the file is opened for the second and subsequent times.
    The workaround is to declare a module-level variable in ThisWorkbook and use the following code construction:
    Please Login or Register  to view this content.
    Artik

  5. #5
    Registered User
    Join Date
    11-30-2021
    Location
    Basingstoke, England
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Refresh all pivot tables when emailed spreadsheet is opened

    Bullseye! That's great! Thank you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Refresh Pivot Tables
    By wherdzik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2020, 08:35 AM
  2. cannot get pivot tables from VBA to refresh
    By randallrosa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2017, 03:16 AM
  3. Refresh Data Tables from Pivot Tables
    By JJones5 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-15-2016, 03:12 PM
  4. VBA Refresh all does not refresh pivot tables
    By cmorten82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2016, 04:32 PM
  5. Replies: 1
    Last Post: 06-06-2016, 02:29 PM
  6. [SOLVED] Changing Pivot Table Source- Code Created Files Require Manual Refresh Each Time Opened
    By Aquamore in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2015, 05:53 PM
  7. [SOLVED] refresh pivot tables
    By bp in forum Excel General
    Replies: 5
    Last Post: 04-04-2006, 02:45 PM

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