简体   繁体   English

从Sharepoint打开文件时Excel .xlsx VBA ADODB连接错误

[英]Excel .xlsx VBA ADODB connection error when opening file from sharepoint

I am trying to read a file from sharepoint location. 我正在尝试从共享点位置读取文件。 The code works absolutely fine when reading from local drive. 从本地驱动器读取时,该代码可以正常工作。 Please also note that the file type is .xlsx If I convert the file into .xls the code works fine regardless whether the file is on the server or on the local path. 另请注意,文件类型为.xlsx如果将文件转换为.xls,则无论文件在服务器上还是本地路径上,代码都可以正常工作。

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & dataPath & ";" & _
        "Extended Properties=""Excel 8.0;HDR=No;"";"

Error received 收到错误

External table is not in the expected format. 外部表格的格式不正确。

Connecting directly to sharepoint server to access a file creates a lot of problems. 直接连接到sharepoint服务器以访问文件会产生很多问题。

For Example 例如

  • 1 of the issue is already described above; 上面已经描述了其中的1个问题;
  • 2 issue is that you would have to manually connect to sharepoint everytime the computer starts before the program can read the file. 第2个问题是,每次计算机启动时,您都必须手动连接到sharepoint,然后程序才能读取文件。

A better way of connection can be found in the following answer: 更好的连接方式可以在以下答案中找到:

Get the content of a sharepoint folder with Excel VBA 使用Excel VBA获取共享点文件夹的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM