【发布时间】:2015-07-16 23:38:21
【问题描述】:
我正在尝试打开一个文件名每周都会更改的文件。这意味着文件名上的日期部分是不同的。此外,此文件是文件夹内的唯一文件。但它的文件名正在改变。我正在使用下面的代码,但它抛出了错误,“运行时间 52:错误的文件名和编号”。我需要你的帮助。
Dim ThePath As String
Dim TheFile As String
ThePath = "https://ts.company.com/sites/folder1/folder2/folder3/folder4/"
TheFile = Dir(ThePath & "MANILA_ShiftRecord_*" & ".xlsx")
Workbooks.Open (ThePath & TheFile)
谢谢!
【问题讨论】:
-
您不能在 http 路径上使用
Dir()。您可以使用 WebDAV 路径,具体取决于它的托管方式。 -
stackoverflow.com/a/24221462 这是 VBA 代码,它将解析 WebDav URI 并允许 VBA 直接从 SharePoint 打开文件。
标签: vba excel sharepoint sharepoint-2010