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

tonymaclaren

New Member
Joined
Dec 16, 2018
Messages
3
I desperately hope someone can help.I have some simple VBA code that makes a copy of a 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 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 manually with no problem whatsoever !

It is not a .csv problem as I originally thought because the same problem occurs with .xlsx in testing.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Maybe

Code:
[LEFT][COLOR=#333333][FONT=Verdana]ActiveWorkbook.SaveAs Filename:="https:// blah /bla".[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana], FileFormat:=6, CreateBackup:=False, [/FONT][/COLOR][/LEFT][COLOR=#0000ff][LEFT][FONT=Verdana]accessmode:=xlShared[/FONT][/LEFT][/COLOR][LEFT][COLOR=#333333][FONT=Verdana][/FONT][/COLOR][/LEFT]
 
Upvote 0
Thank you Kamolga. That does not work at all. It compiles but throws the 1004 error even on my machine.
FileFormat:=6, CreateBackup:=False, _
accessmode:=xlShared

accessmode:=xlExclusive works on my machine burt not on the clients.
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,770
Members
449,095
Latest member
m_smith_solihull

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