"same code as before." The code before was what I am trying in VB.NET, the second post is the original VBA from which it came.
" ws means Workbook", yes, and wb means workbook, always Dim wb as Workbook
"your code works fine if you re-define oConn to ODBC Connection?
The code does not even work yet, I'm still trying to get it to compile!
The line "For Each oConn In wb.Connections" is giving a compile error
'Error 159 Value of type 'NetOffice.ExcelApi.WorkbookConnection' cannot be converted to 'NetOffice.ExcelApi.ODBCConnection'.
I can see from the Object Browser
Public Class Connections
Public ReadOnly Property Connections As NetOffice.ExcelApi.Connections
Member of NetOffice.ExcelApi._Workbook
If I Dim oConn as WorkbookConnection I can then iterate,
and I can type oConn.ODBCConnection
I can see
Public Property CommandText As Object
Member of NetOffice.ExcelApi.ODBCConnection
So that tells me I can do this:
For Each oConn In wb.Connections
vItem(1) = TypeName(oConn)
vItem(2) = oConn.ODBCConnection
vItem(3) = oConn.ODBCConnection.CommandText
vItem(4) = oConn.ODBCConnection.CommandType
So that tells me I have to write separate code for OLEDBConnection, although VBA seems to allow a mixture.
OK, I can do that.