Home

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

Highlighted
tonymaclare10
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:

Sheets("Data").Select
Sheets("Data").Copy

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
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies