PDA

View Full Version : Saving to OneDrive using VBA powerpoint



letsdogethel
10-26-2018, 01:35 AM
Apologies for lack of forum etiquette (first post)

I am trying to make a button in powerpoint that will save a copy of the powerpoint to onedrive.
why not just use the menus you may ask? well the macro also removes the VBA code.

The problem is the code I am using is incredibly slow. Typically, a 75mb powerpoint will appear in the onedrive folder immediately if you save conventionally
but will take over a minute using a macro button. Using VBA, a dialogue box appears with the "uploading to sharepoint" dialogue box which prevents the user from
doing anything for the duration.

code below
ActivePresentation.SaveAs FileName:= _
"https://companyname-my.sharepoint.com/personal/john_doe_companyname_com/Documents/testpowerpointfile.ppsx"

The above code is what the macro recorder in Word and Excel suggest. Unfortunately, microsoft removed the recorder for powerpoint so I have no idea how it is supposed to be done
to reduce the upload time. any help appreciated

Paul_Hossler
10-26-2018, 07:41 AM
Q: SharePoint or OneDrive?

John Wilson
10-27-2018, 06:34 AM
As Paul says SharePoint or One Drive?

Assuming you do mean OneDrive

Call ActivePresentation.SaveAs(FileName:="https://d.docs.live.net/Your CID/testing2.pptx")
OR
Call ActivePresentation.SaveAs(FileName:="https://d.docs.live.net/Your CID//Documents/testing2.pptx")

Your CID will be an 8 digit Hex number (ie 16 characters e.g. EAF7126A7B9FA22E) to get this go to onedrive.live.com and log in. It will show in the address bar.

letsdogethel
10-29-2018, 03:52 AM
When I open Onedrive from portal.office.com, the url is as https://companyname-my.sharepoint.com.
As I mentioned previously, using the macro recorder from excel or word to save to 'onedrive' conventionally yields the following:


ChDir "C:\Users\john.doe\OneDrive - COMPANY NAME LIMITED"
ActiveWorkbook.SaveAs Filename:= _
"https://companyname-my.sharepoint.com/personal/john_doe_companyname_com/Documents/Book1.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

From this I believe it is sharepoint but it is called one drive sometimes

John Wilson
10-29-2018, 12:11 PM
OneDrive for business uses SharePoint (as opposed to One Drive Personal

That said your original code looks correct and the equivalent here runs quickly (It is a small file though but we have a very slow connection)