在SharePoint中尝试“打开文件进行输入”时出现运行时错误52

时间:2018-08-13 18:43:06

标签: excel excel-vba sharepoint

尝试读取SharePoint中保存的txt文件中的特定字符串。如果我使用这个:

path1 = "https://company.sharepoint.com/sites/Presales/Shared Documents/"
path2 = "Sales Planning/"
csvFile = path1 & path2 & "Auth.txt"
Workbooks.Open Filename:=csvFile

它按预期工作(打开文件)。如果我编写我真正想要的代码:

path1 = "https://company.sharepoint.com/sites/Presales/Shared Documents/"
path2 = "Sales Planning/"
csvFile = path1 & path2 & "Auth.txt"
fnum = FreeFile
Open csvFile For Input Access Read As #fnum

我收到运行时错误'52':错误的文件名或数字。文件名不能错,因为在第一种情况下它可以工作。对于“数字”,我怀疑如果是指fnum,但是我使用了fnum = FreeFile,那怎么了?

0 个答案:

没有答案