The number of Queries & Connections in a workbook isn't necessarily the same - example with one of my workbooks:
Sub QueriesAndConnectionsCount()
Dim WB As Workbook
Set WB = ThisWorkbook
With WB
Debug.Print .Queries.Count 'Result: 5
Debug.Print .Connections.Count 'Result: 3
End With
End Sub
So looping with a For i = x to something.Count isn't a good option IMHO. Where possible work with collections and iterate with a For Each
The following should do what you want (in a Module):
Option Explicit
Sub DeleteAllQueriesAndConnections()
Dim Wbook As Workbook
Set Wbook = ThisWorkbook
Call DeleteAllQueries(Wbook)
Call DeleteAllConnections(Wbook)
End Sub
Sub DeleteAllQueries(WB As Workbook)
Dim WbQuery As WorkbookQuery
With WB
For Each WbQuery In .Queries
WbQuery.Delete
Next
End With
End Sub
Sub DeleteAllConnections(WB As Workbook)
Dim WbCon As WorkbookConnection
With WB
For Each WbCon In .Connections
.Connections(WbCon.Name).Delete
Next
End With
End Sub