SharePoint establishing a UNC manually

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,113
Office Version
  1. 365
Platform
  1. Windows
Good Day,

Using SharePoint, I've noticed the path is https which are not a structured location for a file transfer and know that this is not an isolated issue.

My question is how do use a UNC path instead of (\\SharePointServer\Path\MorePath\DocumentLibrary\Folder) and express this through VBA code?

I would assume that the VBA code will have to first check for https and then covert the path to UNC manually.

Please let me know, which settings are used upon my SharePoint server for this to happen.

I know there are quite a few articles on this subject but none officially from Microsoft.

Please let me know!

Thank you!
pinaceous
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
It is not possible to directly access a SharePoint document library using a UNC path. However, you can access SharePoint document libraries through the File System Object (FSO) in VBA code.

To do this, you will need to map your SharePoint document library as a network drive on your computer.

To map a SharePoint document library as a network drive:

  1. Open Windows Explorer and click on "This PC" in the left navigation panel.
  2. In the top ribbon, click on "Map network drive".
  3. In the "Folder" field, enter the URL of the SharePoint document library you want to map.
  4. Select a drive letter for the network drive.
  5. Check the "Connect using different credentials" box.
  6. Enter your SharePoint login credentials.
  7. Click "Finish".
Once you have mapped the SharePoint document library as a network drive, you can access it using the FSO in your VBA code like any other network drive.

Here is an example of how you can use the FSO to access a file in a SharePoint document library using VBA:

Copy code
Dim fso As FileSystemObject
Set fso = New FileSystemObject

Dim file As file
Set file = fso.GetFile("X:\Folder\file.txt")

'You can now use the "file" object to access the file and read or write to it as needed.

You will need to replace "X:\Folder\file.txt" with the path to the file on the mapped network drive.
 
Upvote 0
Hey hydraulicwave,

I appreciate that you were able to respond to my post! In working with your list:

Rich (BB code):
To map a SharePoint document library as a network drive:

  1. Open Windows Explorer and click on "This PC" in the left navigation panel.
  2. In the top ribbon, click on "Map network drive".
  3. In the "Folder" field, enter the URL of the SharePoint document library you want to map.
  4. Select a drive letter for the network drive.
  5. Check the "Connect using different credentials" box.
  6. Enter your SharePoint login credentials.
  7. Click "Finish".

I'm curious about:

Rich (BB code):
 2. In the top ribbon, click on "Map network drive".

It seems to provide two different drive pathways.

For example, if I go to the left-hand column, I obtain a different URL than from the SYNC site.

The left-hand column provides:

Rich (BB code):
C:\Users\MYUSERID\Main Drive Folder\Main Folder1 - Folder1\Folder2\TEST.xlsm

& the SYNC site provides:

Rich (BB code):
https://sharepoint.com/sites/Main Folder2/SharedDocuments/General/FolderA/FolderB/FolderC/FolderD/FolderE/FolderF/FolderG/Folder1/Folder2\TEST.xlsm


Could you possibly explain what is going on here? For example, why are their seemingly two different drive pathways?

If in using the one with the letter as in #4, I'll have to test it out.

Thank you!
pinaceous
 
Upvote 0
When you map a SharePoint document library as a network drive, it creates a shortcut to the library on your computer. This allows you to access the library as if it were a local drive, rather than having to navigate to the library through the web interface. The drive letter you select in step 4 is a way for you to specify a specific local drive letter to be associated with the SharePoint library.

The URL you see in the left-hand column of Windows Explorer is the local path to the mapped network drive, while the URL you see on the SYNC site is the web address of the SharePoint library. These are two different ways of accessing the same set of files, but the local path will be faster and more convenient to use, since it doesn't require an internet connection.

The difference in the path may occur if you have set different folder structure in the SharePoint library and on your local drive or if you are looking at different folders or libraries on the SharePoint site.
 
Upvote 0

Forum statistics

Threads
1,215,101
Messages
6,123,096
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top