I'm seeking some advice on the use of SaveAs when saving a workbook to SharePoint.
I have some code which creates a simple workbook, populates it with some data and saves it to a chosen destination folder. This works perfectly when a local drive is selected for the destination folder. If it's run a second time with the same destination folder, I get the usual warning that the filename already exists and, if I accept, it replaces the old file with the new copy perfectly. However, if I select a SharePoint location as the destination, after warning me that the filename already exists, I get a Run-time error '1004': Method 'SaveAs' of object '_Workbook' failed.
It's interesting to note however that if I sandwich the SaveAs line between On Error Resume Next ... On Error Goto 0, it does actually save the workbook. Whilst this workaround works, I don't feel comfortable knowing that there's something wrong with it. I've seen others asking about this problem, but have never managed to find a definitive cause or solution. The code below is a stripped down version of my code with just the pertinent bits... but it behaves exactly the same.
Any advice gratefully received.Please Login or Register to view this content.
Bookmarks