Hi everyone,
I'm trying to change Command Text box in Connection Properties (see picture). It is an existing data connection in Excel and I need to change the query.
I already found this thread discussing altering Connection String but I was not able to alter the code for my purposes. What I tried is this:
Also I added system.data.oledb into object's name space but it seems "CommandText" is not part of OLEDBConnection, although it is property of OLEDBConnection here.
I don't know what to do now.
I'm trying to change Command Text box in Connection Properties (see picture). It is an existing data connection in Excel and I need to change the query.
I already found this thread discussing altering Connection String but I was not able to alter the code for my purposes. What I tried is this:
Code:
Dim wb As Object
wb = GetWorkbook(handle, workbookname)
Dim oledbCn As OLEDBCommand
oledbCn = wb.Connections(connectionname).OLEDBConnection
query = oledbCn.CommandText
Also I added system.data.oledb into object's name space but it seems "CommandText" is not part of OLEDBConnection, although it is property of OLEDBConnection here.
I don't know what to do now.