VBA & One Drive RRS feed

  • Question

  • Hi,

    I have to save everyday an excel file in OneDrive, but this is not my onedrive, it is the one of my manager that so the "physical" folder is not in my computer.

    This file is a report generated by VBA. Before I was used to sent it by mail (created by code) to a list of person. Now they decided to share this report in One Drive.

    I tried with code to move a file, also with another code to save online but no one of them works.

    Now with VBA code I'm opening this one drive and manually I'm moving this file. I'd like anyway to complete the operation by code.

    Could you please tell me how to do?

    Thank You


    this is what I already used without success


    Sub ApriOneDrive()

        Dim URL As String
        URL = "https://XXXXXXXX-my.sharepoint.com/personal/XXXXXX.com/_layouts/xx/onedrive.aspx?id=%xxxx%XXXXXX%XXXXXXX%5Fcom%2FDocuments%2FEDI%XXXXXX%XXXXXX%XXXXX%XXXX%XXXX%20work&originalPath=aHR0cHM6Ly9tZWR0cm9uaWNlbWVhLW15LnNoYXJlcG9pbnQuY29tLz......."

         ActiveWorkbook.FollowHyperlink URL
    End Sub
    the second :
    Sub MoveFiles()
        Dim FSO As Object
        Dim URL As String
        Dim SourceFileName As String, DestinFileName As String

        URL = "https://xxxxxxx-my.sharepoint.com/personal....."

        Set FSO = CreateObject("Scripting.Filesystemobject")
        SourceFileName = "K:\xxxxx\0xxxx\PROJECTS\32.xxxxxxject\xxxx\xxxx"
        DestinFileName = URL & "/xxxx"
        FSO.MoveFile Source:=SourceFileName, Destination:=DestinFileName

        MsgBox (SourceFileName + " Moved to " + DestinFileName)
    End Sub
    or this:     Sub SaveinOneDrive()
        ActiveWorkbook.SaveAs FileName:= _
            "https://d.docs.live.net/xxxxxxxxx/test.xlsm", FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    End Sub

    Wednesday, July 29, 2020 7:36 PM