Unable to connect to Excel file in OneDrive - excel

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?
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. Once file is available there are many routines already on SO to import data.
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. You can even access network locations if they're included in the PC's libraries or mapped as drives. When you browse a PC's files remotely, you can download copies of them to work on. 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. OneDrive also needs to be running on that PC, and the Fetch files setting must be selected. For further Details please refer Fetch files on your PC
C.) FIle on ShareOint - VBA aopproach If your file is on SharePoint. OneDrive doesn't sync the shared files to the local and sync. In such case VBA code is available on SO VBA download a File from OneDrive by #Sid29
D.)REST APIs - Microsoft Graph Another situation is elaborated in the following paragraph which uses 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. 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.
These REST APIs are a part of the Microsoft Graph, a common API for Microsoft services.
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. OneDrive and SharePoint in Microsoft Graph
E.) It may be difficult to get url of specific online file of onedrive. 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.
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.
Though it depends on the web site , code mentioned in article executed successfully using IE browser. Code mentioned in this article can be experimented with. There is no other method to load online onedrive file through VBA in my knowledge.

Related

How to apply ThisWorkbook.SaveCopyAs with SharePoint path?

I have a line:
ThisWorkbook.SaveCopyAs Filename:="https://pmicloud-my.sharepoint.com/personal/yisaev_grintl_net/Documents/Book2.xlsm"
It returns an error:
"Sorry we couldn't find path [path string here]. Is it possible it was moved, renamed or deleted?"
Function .SaveCopyAs works with the path on a computer drive, but not with web site like SharePoint, when other options (Workbooks.Open and Workbooks.SaveAs) work with the same path to SharePoint.
Well excel wants to save the file to a hard drive. Saving to an URL is not the same thing.
The SharePoint URL is a web interface displaying data on a network drive. If you have access to that network drive you can directly save the file there.
Otherwise you will have to save the file and upload it manually.
Obviously Microsoft added some support for sharepoint over http(s), but it does not support the .SaveCopyAs method:
You can vote for this feature here:
Improve *Workbook.SaveCopyAs VBA method - support SharePoint / OneDrive

Connecting existing document library to sharepoint site

I was experimenting with MS Flow in Office 365, trying to automatically extract info from excel files. However, it turns out we made some "design error" in our sharepoint structure.
We have multiple central document libraries that are only linked to the Onedrive for Business environment and not connected to a Sharepoint site. (The latter turns out to be necessary for MS flow.) Is it possible to link existing document libraries to a sharepoint site?
EDITS:
Some background: within onedrive for business we have created multiple document libraries. See the screenshot below (blacked out are the ones we created).
Screenshot of Onedrive for Business "Site Contents"
Using MS flow I want to extract info from some of the Excel sheets in those doc libs. However, when using the wizards, I can only access files in document libraries that are created from a Sharepoint site (mine were apparently created directly in the OnedrivefB environment) or the main document library from OnedrivefB (as shown below; when choosing Onedrive, the File wizard only shows the files in the 'Documents' doc lib as also listed in the previous screenshot. Screenshot from Flow wizard
Elsewhere, I was told I should connect the document libraries we created to a Sharepoint site. But this person couldn't tell me how... Other suggestions are of course welcome as well!
Thanks, J
For completeness:
Step 1 in the wizard, showing sharepoint sites and onedrive for business
Step 2 in the wizard, showing options when choosing for OdfB
Step 3 in the wizard, only showing files from the document library called "Documents" in the first screenshot
A screenshot from one such document library with the Excel I am trying to access
Both OneDrive for Business and Sharepoint sites can be connected to MS Flow. If you are looking for the connection with OneDrive for Business, check the below link for triggers and sample templates
https://us.flow.microsoft.com/en-us/connectors/shared_onedriveforbusiness/onedrive-for-business/
Sharepoint -
https://us.flow.microsoft.com/en-us/connectors/shared_sharepointonline/sharepoint/
EDIT:
To access an Excel file in an OneDrivefB folder, browse and select the excel using file option. It will list all the folders in your OneDrive library.
.Second screenshot which you attached is sharepoint assets. they cant be linked to OneDrive. It can only be linked to sharepoint sites

Office JS API: last saved time?

I develop a Javascript Office add-in which can run on Word, Excel and PowerPoint.
One of the features of the add-in is to suggest user to upload current file to our server if the file have changed and/or saved since the last successful upload.
I had some luck with document.properties.lastSaveTime for Word application: https://dev.office.com/reference/add-ins/word/documentproperties?product=word
But this API is Word-specific and is not available for other hosts.
Is there a way to get the date of last file change (document, workbook and presentation accordingly to the host application) using shared API, that is, API available for all three hosts?
If such shared API functionality doesn't exist, even some clue of how to get last changed date of individual hosts' files would be helpful.

Upload Excel 2013 Workbook to website hosted on Azure

Does anyone have guidance and/or example code (which would be awesome) on how I would go about the following?
With a Web application using C# / ASP.NET MVC and hosted on Azure:
Allow a user to upload an Excel Workbook (multiple worksheets) via a web page UI
Populate a Dataset by reading in the worksheets so I can then process the data
Couple of things I'm unclear on:
I've read that Azure doesn't have ACEOLEDB, which is what Excel 2007+ requires, and I'd have to use OPEN XML SDK. Is this true? Is this the only way?
Is it possible to read the file into memory and not actually save it to Azure storage?
I DO NOT need to modify the uploaded spreadsheet. Only read the data in and then throw the spreadsheet away.
Well that's many questions in one post, let me see if we can tackle them one by one
With a Web application using C# / ASP.NET MVC and hosted on Azure:
1.Allow a user to upload an Excel Workbook (multiple worksheets) via a web page UI
2.Populate a Dataset by reading in the worksheets so I can then process the data
Couple of things I'm unclear on:
1.I've read that Azure doesn't have ACEOLEDB, which is what Excel 2007+ requires, and I'd have to use OPEN XML SDK. Is this true? Is
this the only way?
2.Is it possible to read the file into memory and not actually save it to Azure storage?
1/2. You can allow a user to upload the excel workbook to some /temp location and once you have read you can choose to do the cleanup, you can also write a script which can do the cleanup of the files which couldn't get deleted from /temp for whatever reasons.
Alternatively if you want to keep the files, you should store them in Azure Stoarge, and fetch/read when you need to.
check out this thread read excelsheet in azure uploaded as a blob
By default when you upload a file it is wrote into local disk and one later chooses to save the files to azure storage or whatever places.
Reading the excel - you can use any of the nugget packages given here http://nugetmusthaves.com/Tag/Excel and read the excel file, I prefer Gembox and NPOI
http://www.aspdotnet-suresh.com/2014/12/how-to-upload-files-in-asp-net-mvc-razor.html

SharePoint Online file storage

We have a requirement to store documents in SharePoint Online as people copy files to a shared network directly.
Is there a way of automating this? I was thinking of a windows service which will poll the directories, find any changes like new subdirectories or new files, then upload them to a SharePoint Online document library.
You don't have to poll if you use a FileSystemWatcher inside your Windows service for real-time notifications.
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
However, if your requirement is 100% accuracy, you will need to build in some sort of tracking/checksum mechanism to make sure that every document was 1) detected and 2) successfully moved to SharePoint.
You may want to have your service check the delta every time it starts up, and then subsequently only respond to FileSystemWatcher events.
EDIT: Per Tony's question below, here are some additional thoughts on getting files to SharePoint.
First, try a simple test.
1) Copy the URL of a document library within the BPOS SharePoint site. Make sure you're on a machine that has the Office Online sign in app on it.
2) Open Notepad. Type some random text.
3) Click on File -> Save As.
4) Paste the URL.
5) Attempt to save the file.
This works great on "regular" SharePoint (done it many times). If this works with BPOS, it opens up several options.
File System Replication to a SharePoint Online or Office 365 document library is planned to be released with the "Cloud Connector for Office 365". With the current version database content is supported only, but bi-directional with V2.0

Resources