|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
可以讲解一下你的这段代码吗。。。
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 |
|