Excel VBA save to Sharepoint path

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Excel VBA save to Sharepoint path

Post by Rudi »

Hi,

How does one create a path to save to a SharePoint location?
I am creating this for someone so I have no way to test this. Basically I just want to know if the structure (ActiveWorkbook.SaveAs sPath & "/" & sFile, FileFormat:=51) I am using is correct? IOW: Must the path be defines as a web path or is there any changes I need to know about?

TX

Code: Select all

    sInv = Worksheets("Inv").Range("D17").Value
    Set rF = Worksheets("InvDue").Range("B:B").Find(What:=sInv, LookAt:=xlWhole)
    sPath = "https://abc.sharepoint.com/Finance/Inv"
    sFile = Replace(rF.Offset(0, -1) & "_" & rF.Offset(0, 13) & "_INVOICE_" & UCase(Format(rF.Offset(0, 3), "DD-MMM-YYYY")) & "_" & rF.Offset(0, 1) & ".xlsx", " ", "_")
    Application.ScreenUpdating = False
    ...
    ...
    ActiveWorkbook.SaveAs sPath & "/" & sFile, FileFormat:=51   'I changed the usual backslash to a forward slash? Not sure if that is right?
    ActiveWorkbook.Close False
    Application.ScreenUpdating = True
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Excel VBA save to Sharepoint path

Post by HansV »

I cannot test it myself either but it looks ok to me.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Excel VBA save to Sharepoint path

Post by Rudi »

TX for the feedback. I have checked some sample from a Google search of SharePoint paths and it didn't give much guidelines? I was just unsure of the slashes and if I could save directly to SharePoint with the same basic path construction as a standard save. I'll have the person test it out and report back. I think that will be the "proof in the pudding" :grin:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.