Hey Everyone,
I am getting an error that says "Invalid Call Procedure or Argument" when I try to delete a workbook connection. The thing is, I use this code in other workbooks and there is no problem. Can anyone see anything wrong, or any reason why I would get this error? Here is the code:
The last line is the problem line. Thanks in advance!
I am getting an error that says "Invalid Call Procedure or Argument" when I try to delete a workbook connection. The thing is, I use this code in other workbooks and there is no problem. Can anyone see anything wrong, or any reason why I would get this error? Here is the code:
Code:
With Sheet2.QueryTables.Add(Connection:="ODBC;DRIVER=SQL NATIVE CLIENT;SERVER=server;Trusted_Connection=Yes;APP=2007 Microsoft Office system;DATABASE=dbtest;" _
, Destination:=Range("Sheet2!$A$1"), Sql:=varSQL)
.Refresh
End With
ActiveWorkbook.Connections(1).Delete