Using VBA to work with folders in Sharepoint

MonteDelMar
MonteDelMar used Ask the Experts™
on
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:

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

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

      http://xxxx111/

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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jamie McAllisterCloud Expert
Most Valuable Expert 2013
Top Expert 2014

Commented:
Just for a test, could you supply a different folder path that doesn't have spaces and see if it works?

Author

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.
Cloud Expert
Most Valuable Expert 2013
Top Expert 2014
Commented:

Author

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial