+ Reply to Thread
Results 1 to 7 of 7

Workbook Open after automatic refresh

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Workbook Open after automatic refresh

    I have some code that finds and replaces text in some columns in different worksheets on opening the workbook.

    My problem is that have some web queries that want refreshing on opening the file and this refresh happens after replacing the text. I want the refresh to happen before finding and replacing the text.

    Thanks,
    Adam.

  2. #2
    Registered User
    Join Date
    11-20-2009
    Location
    Raymond,WA
    MS-Off Ver
    Excel 2002
    Posts
    40

    Re: Workbook Open after automatic refresh

    I'm new to VBA and don't know if this is possible.

    When you save the workbook, can you programmatically 'comment' out the web queries and have your workbook_open procedure 'uncomment' them AFTER the find & replace has run?

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Workbook Open after automatic refresh

    I'm sorry if my original post was not fully clear (i was in a bit of a rush when posting), so i have attached my workbook as an example.

    Hopefully someone can help. Any questions please ask.

    Thanks.
    Attached Files Attached Files

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: Workbook Open after automatic refresh

    Don't have the queries refresh automatically on open. Have the Open event refresh them and then perform your other operations.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Workbook Open after automatic refresh

    ok, sounds like the most simple solution but if i take the automatic refrsh off the queriea on opening the file how do i code the workbook open procedure to refresh the web queries before running the rest o the procedure.

    Thanks,
    Adam.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: Workbook Open after automatic refresh

    This will refresh all querytables:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Workbook Open after automatic refresh

    Thanks, that works great. I have also some more code now to the open workbook procedure which removes the text i want removing and autofits the columns in each the worksheets in the workbook.

    This works fine but i think the way i've written the code for this part must be a long winded way. Is there a neater way of writing this part so it goes through each worksheet in the workbook? Similar to how the beginning of the code goes through each worksheet and refreshes the query tables.

    Please see this latest example.

    Thanks.
    Attached Files Attached Files

+ 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