Excel vba export csv to onedrive works perfectly on my machine but not on clients who has share

New Contributor


I desperately hope someone can help.I have some simple VBA code that makes a copy of a single worksheet and saves it to a shared folder on Business OneDrive, the main bit of code is just:


ActiveWorkbook.SaveAs Filename:="https:// blah /bla".
, FileFormat:=6, CreateBackup:=False

It works perfectly.BUT when I share the folder for my client, it asks for credentials for the correct directory on OneDrive and goes into an infinite loop asking the user to login, receive a code, login again,receive a code......and then gives the error error "1004 method save as of object workbook failed". I should add the client can view the same shared directory and upload the same file or any file manually with no problem whatsoever !
It all seems to have something to do with credentials but only  gives a problem with VBA. Even more strangely in further testing,the VBA worked the first time on both a corporate account and a personal account but the second time it did not work at all on the same accounts with the same credentials.. We had no problem uploading files to the shared folder manually. This problem is delaying a huge Power BI Project for a government client.
3 Replies
Does the user have this Shared OneDrive folder available as a synching folder in his OneDrive folder on his computer? That may fix things.

Thank you for your reply.This is an interesting suggestion, however I am not quite sure how to implement  it. If you could walk me through it would be helpful.The workbook is a standalone app that exports the single "Data" worksheet to MY business OneDrive with VBA. How do I synch MY OneDrive URL directory to the users PC?

It means the user would have to install OneDrive and sign into the account on which he has access to your shared folder. I am not entirely sure however that shared folders are available as synched folders in the OneDrive app.
Related Conversations
Getting #Value!
ranjit995 in Excel on
2 Replies
pratica 1002380750 - query web
Ben_Hur in Excel on
1 Replies
Custom Sheet View is not working in Office 365
RonanK in Excel on
1 Replies
help with macris & VBA
Adil_813 in Excel on
0 Replies
How to count average in certain time range
rutilusss in Excel on
1 Replies
Subtotals or Vlookups or Both.
Kwesi_Quartey in Excel on
7 Replies