title: How do I upload a file to OneDrive Business (Sharepoint) with VBA
body: <p>I'm trying to find a method to upload a file to Onedrive from VBA in Excel.
  I've done a lot of searching for acceptable methods, but most methods will not work for my scenario or the proposed solution will give an error.  </p>
  
  <p>I can upload files just fine if I'm using UNC paths or OneDrive locations that are synced locally (e.g. "C:\Users(username)\OneDrive\File Share") but I need a method that lets me push(upload) files to a shared URL location (e.g. "<a href="https://my.sharepoint.com/:f:/r/personal/(email_address)/Documents/SharedFiles?csf=1&amp;e=6WmUIO" rel="nofollow noreferrer">https://my.sharepoint.com/:f:/r/personal/(email_address)/Documents/SharedFiles?csf=1&amp;e=6WmUIO</a>").  All the users that will need to use the tool will have access to this shared location in OneDrive.</p>
  
  <p>I tried the normal "SaveAs" method in VBA but that won't work.</p>
  
  <pre><code>Set Excelwb = ThisWorkbook
  
  Excelwb.SaveAs fileName:="https://my.sharepoint.com/:f:/r/personal/(email_address)/Documents/SharedFiles?csf=1&amp;e=6WmUIO" _
  , FileFormat:=xlOpenXMLWorkbook, ConflictResolution:=xlLocalSessionChanges
  
  Excelwb.Saved = True
  Excelwb.Close SaveChanges:=False
  Application.DisplayAlerts = True
  </code></pre>
  
  <p>I expected this to save the file, but I understand that since I'm saving to a URL and not a local file that another method is probably required, but I can't find one that will work.  </p>
  
  <p>The error I'm getting is:
  Run-time error '1004'
  Method 'SaveAs' of object '_Workbook' failed</p>