+ Reply to Thread
Results 1 to 5 of 5

Refresh all queries on workbook open, when finished print to pdf then close workbook

  1. #1
    Registered User
    Join Date
    01-23-2014
    Location
    Proserpine, Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Refresh all queries on workbook open, when finished print to pdf then close workbook

    I have data that daily needs to be refreshed and printed to pdf.

    I figure the simplest way to do this would be to task schedule the workbook to open daily.
    Then on open it will refresh the data, print it after all data has been refreshed and close the workbook.

    I set it up originally without the need to print so I have all the queries set to refresh when opening the file, however when I now try and put the code to print to pdf on the workbook open event it runs before the queries are finished running.
    (Query notes:
    queries were created through Microsoft query, and are accessing a MySQL database
    queries set to refresh when opening the file
    queries set to enable background refresh).

    I am very new to scripting so if anybody could provide simple step by step instructions on how I could do this it would be greatly appreciated

  2. #2
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Refresh all queries on workbook open, when finished print to pdf then close workbook

    Can't see the code so I'm guessing....

    Maybe setting a delay can do the trick?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-23-2014
    Location
    Proserpine, Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Refresh all queries on workbook open, when finished print to pdf then close workbook

    Thanks Gerard, but that just seemed to pause the whole app.
    It hung on the splash screen for 3 minutes (that is the time I input) and then printed to pdf, and is now refreshing the queries.

  4. #4
    Registered User
    Join Date
    01-23-2014
    Location
    Proserpine, Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Refresh all queries on workbook open, when finished print to pdf then close workbook

    Think I have it solved.... (more testing this afternoon)
    Went thru all queries and unticked Enable background refresh and refresh on open checkbox options.
    Then in Open sub did a refresh all and then code for printing to pdf. Appears to have worked but still need to test further
    Will update success/failure tomorrow.

  5. #5
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Refresh all queries on workbook open, when finished print to pdf then close workbook

    During splash screen all macro's are on hold.
    If you put the splash screen up for 3 minutes nothing will happen during 3 minutes...... I don't think that was your goal.

    I think you should place the wait code after the query refresh code, before printing.
    Refreshing takes a few seconds......

+ 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. Disable Workbook Open Event Until Other Code has finished Executing
    By dgdgdg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2013, 05:36 AM
  2. Replies: 0
    Last Post: 01-07-2013, 01:22 PM
  3. Replies: 2
    Last Post: 09-11-2012, 09:42 AM
  4. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM
  5. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 PM

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