OLEDB改变连接错误1004

时间:2016-04-15 10:55:06

标签: excel vba oledb powerpivot data-connections

我已就这个问题做了一些调查,但没有任何结果。 我想改变我的PowerPivot连接。我能够更改Access源文件,但在刷新时它会给我一个错误,因为工作簿(突出显示的)连接字符串保持不变。见图片。

PowerPivot wizard

Workbook connection string

我发现这个VBA代码手动更改它,但它给我1004错误。

Sub NewConnection()

  ActiveWorkbook.Connections("Existing Connection name").OLEDBConnection.Connection = "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Desktop\Category Reports\Access DB\Access.accdb;Persist Security Info=false"

End Sub

我尝试了很多代码,但没有一个有效。请帮忙!

1 个答案:

答案 0 :(得分:0)

Apparently Access data base was corrupt, but it was not easy to identify. I have managed to create new data base and re-link it to my excel worksheet via PowerPivot.

Works great!