+ Reply to Thread
Results 1 to 2 of 2

workbook query vba refresh

  1. #1
    Registered User
    Join Date
    03-14-2013
    Location
    Milan, Italy
    MS-Off Ver
    Excel 2019
    Posts
    34

    workbook query vba refresh

    I am having a strange problem with my excel app. The question is very simple: I have a workbook with several queries, and I need to refresh only some of them via VBA. Trying not to run into stupid errors (misspelled names...), I ran a simple proc to get the names of the queries, as follows:
    Please Login or Register  to view this content.
    So far, everything is OK, I get the list of the names of the queries (query1, query2, and so on). Now to refresh the queries I need, I just code
    Please Login or Register  to view this content.
    and this does not work, it fails with the error "runtime error 1004, application defined or object defined error", with every query name I use. After a lot of thinking and searching for help, I found the way out (NOT the explanation). I replaced the queries with the connections. So I ran the test proc:
    Please Login or Register  to view this content.
    and I got the list of the names of the connections,in the format:
    query - query1
    query - query2
    ....

    and now, coding
    Please Login or Register  to view this content.
    no error any longer.

    I find this disturbing, since I don't understand what is going on. Why Excel throws an error with query names? In addition using excel autocompletion, it appears that with connection you could not use "names", but only Index, whereas with query you can use both.But using the index (1,2...) with query does not work anyhow, whereas with connections the name works. Does someone have an explanation other than Microsoft got confused?
    Screenshot 2025-05-31 203353.png

    Screenshot 2025-05-31 204732.png

  2. #2
    Registered User
    Join Date
    03-14-2013
    Location
    Milan, Italy
    MS-Off Ver
    Excel 2019
    Posts
    34

    Re: workbook query vba refresh

    For Anyone who is interested, I can provide an answer... The problem only happens in Office2024. Using Office2019, office2021 or office365, everything works as expected without errors. So it appears that the error is due to some Microsoft "correction".

+ 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 query in workbook open and sheet activate
    By Undo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2022, 12:25 PM
  2. refresh query in workbook open and sheet activate
    By Undo in forum Excel General
    Replies: 0
    Last Post: 05-20-2022, 06:15 AM
  3. [SOLVED] How to refresh workbook query assiociated with PowerQuery based on query name?
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-06-2021, 09:22 AM
  4. Refresh query on saving workbook
    By Joy C in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-03-2011, 12:12 PM
  5. Refresh query with a password protected workbook.
    By Joy C in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2011, 12:31 PM
  6. Query refresh in a shared workbook
    By ACurtis802 in forum Excel General
    Replies: 0
    Last Post: 04-01-2009, 05:29 AM
  7. Supress Query Refresh dialog on opening workbook
    By Paul Tugwell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2005, 07:05 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