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
excel formula
loriam1225 in Excel on
0 Replies
Process the big data
yoepls in Excel on
0 Replies
Row height
yorkiebasie in Excel on
1 Replies
Load the Analysis ToolPak plugin in Excel
Daniel10 in Excel on
0 Replies
Cant understand why i cant apply formula
Kwaker in Excel on
10 Replies
Getting data from web
PeterG380 in Excel on
0 Replies