Hello,
I am using the following code to remove all connections and queries in a workbook, however, it does not work I still see all the connections and queries in the workbook, any idea why it is not working?
Thanks,
I am using the following code to remove all connections and queries in a workbook, however, it does not work I still see all the connections and queries in the workbook, any idea why it is not working?
VBA Code:
Sub RemoveAllConnectionsAndQueryTables()
Dim cn As Variant
Dim qt As QueryTable
Dim ws As Worksheet
For Each cn In ThisWorkbook.Connections
cn.Delete
Next
For Each ws In ThisWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Delete
Next qt
Next ws
End Sub
Thanks,