Change Excel Odbc Connection?Oct 6, 2009
I have an excel with 10 sheets, each sheet has a connection stored in it because i am using the ms query to read data from access database. when I code the below, both line are accepted by vb.net (with new or without)
Dim wb1 As Excel.Workbook
Dim wb2 As New Excel.Workbook
Now when I code
Dim wb_cnn1 As Excel.ODBCConnection ' Works Fine
Dim wb_cnn2 As new Excel.ODBCConnection ' Error 'New' cannot be used on an interface.
Q1: Why I cannot create New Excel.ODBCConnection? I have this
Dim xlsApp As New Excel.Application
Dim wb_cnn As Excel.ODBCConnection
Dim wb As Excel.Workbook
Maybe because it is read only. I want that because the ms query is hardcoding the path of the access db even if i choose DSN so, if I change the location of the access file the query in the excel will not work, Q2: How I can change the connection in the Excel sheet?