Refresh all connections VBA
Results 1 to 2 of 2

Thread: Refresh all connections VBA
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jul 2014
    Location
    Anywhere
    Posts
    443
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Refresh all connections VBA

    Some of my workbooks have a connection that pulls data from a website.
    I need to batch open those workbooks and update the connection.
    The problem is that the code is not working, I suppose that's because I was unable to be "BackgroundQuery: = False" before reflashall and not wait until update is done.
    Need help with this code.
    Thanks.
    Using Excel/Word 2010.
    Backup your original file before doing any modification.

  2. #2
    Board Regular
    Join Date
    Jul 2014
    Location
    Anywhere
    Posts
    443
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Refresh all connections VBA

    After a extense google search I found something that is working (with some my modifications):

    Code:
    Set oWkb = Activeworkbook
    For Each oSheet In oWkb.Worksheets
        For Each oQt In oSheet.QueryTables
           oQt.BackgroundQuery = False
           oQt.Refresh
           DoEvents
        Next oQt
    Next oSheet
    Thanks
    Last edited by eduzs; Jun 20th, 2019 at 01:16 PM.
    Using Excel/Word 2010.
    Backup your original file before doing any modification.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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