Excel Macro problems when working on sharepoint folders

Occasional Visitor

I am using Excel VBA to automate some processes with a synced local copy of sharepoint folders.  Here are two annoying things I am having. 

1. The macro will open excel files and make some changes. Then save and close the file.   But the macro will stop randomly showing "Document not saved" error.  After I click debug and continue, the macro can resume working.   The internet is working great with no interruptions.  I am not sure why this happens. 

Here is the code where the error happens. 

Workbooks(CurFileName).Close True 


2. After I processed all documents, I will have to move folders to the processed folder.  Even I closed all documents and windows and wait over 15 minutes.  I still get errors like "Permission denied".  I have to restart my computer to get the folder lock removed.   

Here is the code where the error happens. 

Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.MoveFolder MyOldPath & CurFolder, MyPath & CurFolder


Please help me with these annoying mistakes!  Thanks

0 Replies