excel - Open SharePoint file into desktop version of Excel
问题描述
I have the following code that has worked perfectly for many years:
palName = "S:\STAGE GATE\New Stuff 2021.xlsm"
(value is typically taken from a cell rather than hard coded)
Workbooks.Open Filename:=palName, UpdateLinks:=False
However, recently some of the locations for the files are from sharepoint so the palName would be as follows:
palName = "https://workwork.sharepoint.com/:x:/r/sites/newStuff/New%20Stuff%202021.xlsm?d=xyz&csf=1&web=1&e=123"
The usual Workbooks.Open does not work for these files. I would like to open the file in the desktop version of excel so I can copy data out of it. Is a new method required I can I adapt the Workbooks.Open accordingly to meet my needs.
Many thanks in advance, Alan.
解决方案
I had this issue also. First, you have to fix something in the excel options. So, go to File > Options > Advanced > then scroll down until you see Link Handling > then select the box that says "Open Supported hyperlinks to Office in Office Desktop Apps". Next, I used the coding below to get the link to work. you just need to reply the part of the coding with you sites url sharepoint file. the only issue I came up with is that you have to run the coding below, wait for the file to completely load, and then you can run macros on this file.
Sub OPEN_YRLY()
'
' OPEN_YRLY Macro
'
'
Range("C1").Select
ActiveWorkbook.FollowHyperlink Address:="https://aramark365-my.sharepoint.com/:x:/r/personal/......", NewWindow:=False, AddHistory:=True
End Sub
推荐阅读
- json - JSON 文件未正确显示阿拉伯语/波斯语字符
- r - 将函数应用于数据框列的每个元素
- python - Excel VBA 将参数传递给 Python 脚本
- docker - 将 docker 卷的挂载点更改为自定义目录
- c++ - 如何按位置获取窗口控制(win32 API)?
- r - 如何在另一列包含指定字符串的情况下设置NA?
- python - 如何在不重新训练的情况下简单地加载 ML 模型?
- api - 如何在没有状态管理的情况下访问 Flutter 应用中的 50 多个 api?
- android - 滚动期间调用 MPAndroidChart 图表值选定的侦听器
- java - Android UDP 打孔