I'm trying to open an Excel file from SharePoint using VBA. Because the file I'm looking for might be different each time I run the macro, I want to be able to view the SharePoint folder and select the file I need.
The code below works fine when I want to look for a file on a network drive, however when I replace that with a SharePoint address I get "run-time error 76: Path not found".
Sub Update_monthly_summary()
Dim SummaryWB As Workbook
Dim SummaryFileName As Variant
ChDir "http://sharepoint/my/file/path"
SummaryFileName = Application.GetOpenFilename("Excel-files,*.xls", _
1, "Select monthly summary file", , False)
If SummaryFileName = False Then Exit Sub
Set SummaryWB = Workbooks.Open(SummaryFileName)
End Sub
When I paste this address into Windows Explorer I have no problems accessing the SharePoint folder, so I know the path is correct.
Why doesn't VBA like it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…