chuckchuckit
Well-known Member
- Joined
- Sep 18, 2010
- Messages
- 541
I am trying to determine if a "Data Connection" has been deleted by looking to see if the connection name still exists. I know the connection name, but do not know the code line that would tell me if it exists.
Here is the code I am using so far:
Above code loops and gets names of all data connections that exist. Later I will delete one of those connections by its name using code:
If it errors and does not delete it (such as due to the connection still being used in a query) I am choosing to use code:
And then test to see if that connection no longer exists (which means it did get deleted). If it still exists I'll continue to try to delete it until I see that it no longer exists.
But I can not find this needed next line of code that would tell me if that connection is still there or not.
Does anyone know what line of code would tell me such?
Thanks.
Chuck
Here is the code I am using so far:
Code:
Dim TheConnectionName As String
For Each objWBConnect In ThisWorkbook.Connections
TheConnectionName = objWBConnect.Name
Next objWBConnect
Code:
ActiveWorkbook.Connections(TheConnectionName).Delete
Code:
On Error Resume next
But I can not find this needed next line of code that would tell me if that connection is still there or not.
Does anyone know what line of code would tell me such?
Thanks.
Chuck