|
在进行新建数据库查询时出现连接时间非常长,而且有些文件在做查询时,会提该文件是 "不是识别的数据库"什么意思呢?
有进还会自动弹出后台Private Sub Workbook_Open()
Private Sub Workbook_Open()
Dim strCon As String, iPath As String, i As Integer, iFlag As String, iStr As String
strCon = ActiveSheet.PivotTables(1).PivotCache.Connection
Select Case Left(strCon, 5)
Case "ODBC;"
iFlag = "DBQ="
Case "OLEDB"
iFlag = "Source="
Case Else
Exit Sub
End Select
iStr = Split(Split(strCon, iFlag)(1), ";")(0)
iPath = Left(iStr, InStrRev(iStr, "\") - 1)
With ActiveSheet.PivotTables(1).PivotCache
.Connection = VBA.Replace(strCon, iPath, ThisWorkbook.Path)
.CommandText = VBA.Replace(.CommandText, iPath, ThisWorkbook.Path)
End With
End Sub
其中 strCon = ActiveSheet.PivotTables(1).PivotCache.Connection 是用黄色字体显示的,说明什么总题呢,哪里出错了,请高手指点 |
|