Using VBA to work with folders in Sharepoint

Hi Experts

I am trying to get information about a folder on Sharepoint using VBA (Word).

The relevant code is:

       Set fso = CreateObject("Scripting.FileSystemObject")
       fso.GetFolder strPath

The GetFolder bit always gives me an error saying that the path does not exist.

If I open a file from the path in questions and use VBA to return the path, it is:


In theory this is what I pass to the above as strPath.

I have also tried the following formats:

      http://xxxx111/sites/xxx1/ART/DP Marketing (0000)/Brochure Designs
      http://xxxx111/sites/xxx1/ART/DP Marketing (0000)/Brochure Designs/
      http://xxxx111\sites\xxx1\ART\DP Marketing (0000)\Brochure Designs
      http://xxxx111\sites\xxx1\ART\DP Marketing (0000)\Brochure Designs\

The portion of the path


is a mapped drive (P:\) and I have also tried the following formats:

      P:/sites/xxx1/ART/DP Marketing (0000)/Brochure Designs
      P:/sites/xxx1/ART/DP Marketing (0000)/Brochure Designs/
      P:\sites\xxx1\ART\DP Marketing (0000)\Brochure Designs
      P:\sites\xxx1\ART\DP Marketing (0000)\Brochure Designs\

But it still does not work.  Always returns runtime error 52 , bad file name or number.

I am trying to do various other things in other parts of the code, such as create a new folder, but this has similar problems.  I've tried MkDir and MakeSureFolderExists and also fso.CreateFolder.

I can't help feeling that I am missing something obvious but can you tell me what it is, please?

Many thanks.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jamie McAllister MVPSharePoint ConsultantCommented:
Just for a test, could you supply a different folder path that doesn't have spaces and see if it works?
MonteDelMarAuthor Commented:
I will give it a go, Jamie - and thanks for your reply.  The code works if I am writing to the local drive - it's just the UNC path that seems to be the problem.  I cannot try anything until Friday now but will post back then.
Jamie McAllister MVPSharePoint ConsultantCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MonteDelMarAuthor Commented:
Sorry, I wasn't able to test this until today.  It was doen to the format I was using for the UNC path - I needed to remove the 'http' portion and replace all the forward slashes with backslashes.  Thank you for your help, Jamie.  I had tried changing the slashes but would never have thought to remove http.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.