Save File to SharePoint Site

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
608
I can download files from SharePoint through VBA. But I can't seem to save the file back to SharePoint under a different name. I get a "Run-time error '1004': Method 'SaveAs' of Object '_Workbook' failed. Does anyone have any suggestions?
My line of code is:

HTML:
ActiveWorkbook.SaveAs Filename:= _
        "https://central.xxxx.com/corp/acctg/projects/Project Accounting/Chembio/Enzymes/Project Management/201011 Billing - 2121.xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I can download files from SharePoint through VBA. But I can't seem to save the file back to SharePoint under a different name. I get a "Run-time error '1004': Method 'SaveAs' of Object '_Workbook' failed. Does anyone have any suggestions?
My line of code is:

HTML:
ActiveWorkbook.SaveAs Filename:= _
        "https://central.xxxx.com/corp/acctg/projects/Project Accounting/Chembio/Enzymes/Project Management/201011 Billing - 2121.xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Hi Mike,
You have hard coded your file path & file name. Without this info, excel will save where the file cam from and with the current name, so perhaps just try
ActiveWorkbook.Save
Hope that helps
 
Upvote 0
Oops. I meant to upload the "variable-version" of what I was doing. In the meantime I discovered that if I leave off the FileFormat: and CreateBackup: section of code, it works just fine. Here is the code as I am now doing it:


HTML:
ActiveWorkbook.SaveAs Filename:=TheFile
Where TheFile is the variablized text I containing the path and file name. The file name is different from the name I downloaded from SharePoint. However it works fine as long as I don't have the additional code

HTML:
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,591
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top