In relation to my previous question, I am trying to capture connection errors from Data > Connections.
I have added a test connection to check to see if my code works correctly, however, when refreshing the connections, a built in Excel dialog will appear:
Is there anyway to overwrite this dialog with the custom MsgBox as shown:
Dim cn As WorkbookConnection
On Error GoTo ErrorHandler:
For Each cn In ActiveWorkbook.Connections
cn.Refresh
Next
'On Error GoTo 0
Exit Sub
ErrorHandler:
MsgBox "A connection could not be reached" & ": " & cn.name & ": " & cn.Description
LATEST EDIT: This is how my code currently looks -
Dim cn As WorkbookConnection
Application.DisplayAlerts = False
For Each cn In ActiveWorkbook.Connections
cn.Refresh
On Error GoTo ErrorHandler:
Next
'On Error GoTo 0
Exit Sub
Application.DisplayAlerts = True
ErrorHandler:
MsgBox "A connection could not be reached" & ": " & cn.name & ": " & cn.Description