Establish Connection to Network Drive (not mapped)

pvans267

New Member
Joined
Feb 25, 2010
Messages
35
Good evening,

Please can someone help with this.

I have a macro workbook that accesses a SharePoint folder to import some modules. This works perfectly well if the user has mapped the SharePoint drive to their computer (I guess because Windows establishes a connection to this drive when logging in).

However, if the user has not mapped the drive, it cause a Runtime Error 52. If I manually open the folder in Windows Exporer (without mapping, just typing the address in Windows explorer) and then re run the macro, it works perfectly.

Code:
Code:
Sub GetCodeLibModules

Dim strFileName As String

MODEL_OUTPUT_MODULE_FOLDER = "\\Sharepoint....."

strFileName = Dir(MODEL_OUTPUT_FOLDER)

Do While Len(strFileNAme) > 0
    ThisWorkbook.VBProject.VBComponents.Import (MODEL_OUTPUT_MODULE_FOLDER & strFileName)
    strFileName = Dir
Loop

End Sub

Is there a way, through VBA, that I could establish this connection but not open the folder?

Thanks for any help that you can offer
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Thank you for the suggestion.

I would rather not physically map the network drive, especially considering the fact that I can't guarantee which drives people have mapped and certainly don't want to risk them unmapping a network drive that is critical to their daily tasks.

I have found a method to open the folder using:

Code:
Shell "explorer.exe" & " " & SharepointFileURL, vbNormalFocus

Ideally, I would just like to then terminate that Shell - but haven't managed to find a suitable method of doing this. All I want to do is establish a connection - once that is made, then they (personally) do not need to use the folder, the macro does all the interactions perfectly.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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