none
"We couldn't refresh the connection" - "The query (...) was not found" - Cannot delete connection RRS feed

  • Question

  • Hi,


    I have an Excel file with quite some Power Query data sources and it's almost finished.
    However, whenever I press the "Refresh all" button in the Data ribbon, I get errors like this:

    I suppose these come from connections I created in the beginning, but that I am no longer using.

    When I go to the existing connections modal, I can see the connections giving trouble.
    When I double-click them, the screen just closes and nothing happens. Right-click isn't helping much either: when clicking the only available option to edit, nothing happens.

    

    Is there any way to remove these erroneous connections?

    Have been searching around for a while now but can't manage to remove the connections.


    • Edited by BTB-Tomas Friday, October 5, 2018 6:35 AM
    Friday, September 28, 2018 10:27 AM

Answers

  • Hi Thomas,

    Have you tried deleting the unwanted connections using VBA?

    This can be done in two ways, both of which you can add to your book via the VBA editor (alt+F11) and then execute.

    Sub deleteConnection1()
    Dim Conn As WorkbookConnection
    For Each Conn In ThisWorkbook.Connections
        If Conn.Name <> "a connection I would like to keep" Then
            Conn.Delete
        End If
    Next Conn
    End Sub
    

    Sub deleteConnection2()
        ThisWorkbook.Connections("conn1").Delete
        ThisWorkbook.Connections("conn2").Delete
        ThisWorkbook.Connections("conn3").Delete
    End Sub

    Let me know if it works.

    If possible, please provide me with your Office build information so I can take a closer look regardless, your Office build information is available under File -> Account -> About Excel.

    If you have repro steps for it that would be great as well.

    Ron.

    Thursday, October 11, 2018 7:48 AM

All replies

  • If you delete the queries from the Power Query Editor, do the corresponding connections get removed?

    Ehren

    Monday, October 1, 2018 8:40 PM
    Owner
  • Hi Ehren

    Weird enough, the problem queries are not appearing there, unless I'm missing something:


    Tuesday, October 2, 2018 6:45 AM
  • Ok. Is this Excel 2013 with the PQ plugin, or Excel 2016 with PQ built in?

    Ehren

    Tuesday, October 2, 2018 3:48 PM
    Owner
  • Excel 2016 with PQ built-in!

    Thanks in advance,

    Tomas

    Wednesday, October 3, 2018 4:08 PM
  • Thanks. I've reached out to the Excel team about this.

    Ehren

    Thursday, October 4, 2018 5:58 PM
    Owner
  • Great, thanks.
    Looking forward to your reply.
    Friday, October 5, 2018 6:35 AM
  • Hi Thomas,

    Have you tried deleting the unwanted connections using VBA?

    This can be done in two ways, both of which you can add to your book via the VBA editor (alt+F11) and then execute.

    Sub deleteConnection1()
    Dim Conn As WorkbookConnection
    For Each Conn In ThisWorkbook.Connections
        If Conn.Name <> "a connection I would like to keep" Then
            Conn.Delete
        End If
    Next Conn
    End Sub
    

    Sub deleteConnection2()
        ThisWorkbook.Connections("conn1").Delete
        ThisWorkbook.Connections("conn2").Delete
        ThisWorkbook.Connections("conn3").Delete
    End Sub

    Let me know if it works.

    If possible, please provide me with your Office build information so I can take a closer look regardless, your Office build information is available under File -> Account -> About Excel.

    If you have repro steps for it that would be great as well.

    Ron.

    Thursday, October 11, 2018 7:48 AM
  • I found that If I just made a basic table and named the table the exact same as the one stuck in your data model and just loaded that through power query the data model would adopt that "new" table. Then you can unload it from the data model and delete it from the query and presto you've solved the problem. 
    Thursday, September 12, 2019 1:26 AM