Link to home
Start Free TrialLog in
Avatar of MonteDelMar
MonteDelMar

asked on

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:

      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.
Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

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

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.