简体   繁体   English

无法连接到OneDrive中的Excel文件

[英]Unable to connect to Excel file in OneDrive

I've been searching and searching but with no luck. 我一直在搜寻,但没有运气。 Is there a way to use Excel VBA to import master file data from another excel workbook saved in OneDrive? 有没有一种方法可以使用Excel VBA从OneDrive中保存的另一个Excel工作簿中导入主文件数据?

Thanks in advance. 提前致谢。

A.) If you have an excel workbook that is stored locally on your PC but inside your OneDrive sync-ed folder.Then you can use following VBA code to approach one drive file. A.)如果您有一个excel工作簿存储在您的PC本地但在OneDrive同步文件夹中,那么您可以使用以下VBA代码接近一个驱动器文件。 Once file is available there are many routines already on SO to import data. 文件可用后, SO上已有许多例程可以导入数据。

Sub Test()
Dim fn As String
fn = "Your File " 'change file name

fn = Environ("onedrive") & "\" & fn

'check to see if it exists
If Len(fn) > 0 Then
    Debug.Print fn
End If
'... do something.......
End Sub

B.) FETCH FILES If you have the OneDrive desktop app for Windows installed on a PC, you can use the Fetch files feature to access all your files on that PC from another computer by going to the OneDrive website. B.) 捕获文件如果您在一台PC上安装了Windows版的OneDrive桌面应用程序,则可以通过访问OneDrive网站使用“获取文件”功能从另一台计算机访问该PC上的所有文件。 You can even access network locations if they're included in the PC's libraries or mapped as drives. 如果网络位置包含在PC的库中或映射为驱动器,您甚至可以访问它们。 When you browse a PC's files remotely, you can download copies of them to work on. 当您远程浏览PC的文件时,您可以下载它们的副本以进行处理。 You can also stream video and view photos in a slide show. 您还可以以幻灯片形式流式传输视频并查看照片。 To access files on your PC remotely, make sure the PC you want to access is turned on and connected to the Internet. 要远程访问PC上的文件,请确保要访问的PC已打开并已连接到Internet。 OneDrive also needs to be running on that PC, and the Fetch files setting must be selected. OneDrive也需要在该PC上运行,并且必须选择“获取文件”设置。 For further Details please refer Fetch files on your PC 有关更多详细信息,请参阅在PC上获取文件

C.) FIle on ShareOint - VBA aopproach If your file is on SharePoint. C.)基于ShareOint的文件-VBA aopproach如果您的文件位于SharePoint上。 OneDrive doesn't sync the shared files to the local and sync. OneDrive不会将共享文件同步到本地并同步。 In such case VBA code is available on SO VBA download a File from OneDrive by @Sid29 在这种情况下,VBA代码可用在SO VBA上,通过@ Sid29 从OneDrive下载文件

D.)REST APIs - Microsoft Graph Another situation is elaborated in the following paragraph which uses API. D.)REST API-Microsoft Graph在以下使用API​​的段落中阐述了另一种情况。

The OneDrive REST API is a portion of the Microsoft Graph API which allows your app to connect to content stored in OneDrive and SharePoint. OneDrive REST API是Microsoft Graph API的一部分,它允许您的应用连接到存储在OneDrive和SharePoint中的内容。 The REST API is shared between OneDrive, OneDrive for Business, SharePoint document libraries, and Office Groups, to allow your app the flexibility to read and store content in any of these locations with the same code. REST API在OneDrive,OneDrive for Business,SharePoint文档库和Office组之间共享,从而使您的应用可以灵活地使用相同的代码在任何这些位置读取和存储内容。

These REST APIs are a part of the Microsoft Graph, a common API for Microsoft services. 这些REST API是Microsoft Graph的一部分,Microsoft Graph是Microsoft服务的通用API。

For existing solutions using OneDrive API outside of Microsoft Graph, or solutions targeting SharePoint Server 2016, see direct endpoint differences for more context on reading this documentation. 对于使用Microsoft Graph之外的OneDrive API的现有解决方案,或针对SharePoint Server 2016的解决方案,请参阅直接终结点差异以获取阅读本文的更多上下文。 OneDrive and SharePoint in Microsoft Graph Microsoft Graph中的OneDrive和SharePoint

E.) It may be difficult to get url of specific online file of onedrive. E.)可能很难获得onedrive的特定在线文件的url。 Microsoft Community has covered a situation where they have suggested VBA code for downloading of a file without URL.It is report xlsx from a web application. Microsoft Community解决了一种情况,即他们建议使用VBA代码下载不带URL的文件。这是来自Web应用程序的xlsx报告。 Because the URL isn't the path to the file, it's a 'file request link' it processes single sign on verification, then the download popup is displayed. 由于URL不是文件的路径,因此它是“文件请求链接”,它处理单点登录验证,然后显示下载弹出窗口。 Though it depends on the web site , code mentioned in article executed successfully using IE browser. 尽管取决于网站,但本文中提到的代码已使用IE浏览器成功执行。 Code mentioned in this article can be experimented with. 可以尝试本文提到的代码。 There is no other method to load online onedrive file through VBA in my knowledge. 据我所知,没有其他方法可以通过VBA加载在线onedrive文件。

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

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