Query Tables (QueryTables) in Excel 2010 with VBA with VBA creating many connections

前端 未结 8 712
北荒
北荒 2021-02-06 12:49

I\'m following code I found on another site. Here\'s the basics of my code:

Dim SQL As String
Dim connString As String

connString = \"ODBC;DSN=DB01;UID=;PWD=;Da         


        
8条回答
  •  执笔经年
    2021-02-06 13:38

    I had the same issue. The previous answer while a definite step in the right direction is a PITA.

    It did however allow me to refine my search and the winner is...

    http://msdn.microsoft.com/en-us/library/bb213491(v=office.12).aspx

    i.e. for your existing QueryTable Object just do this:

    .MaintainConnection = False
    

    Works ever so swell. No more Access DB lock file after the data is refreshed.

提交回复
热议问题