[RESOLVED] Connect to/Reference a network folder?
Hello All,
I have a proof-of-concept project that requires my Excel 2010 VBA code to connect to a network location, found under "My Network Places" (It's NOT mapped to a specific drive letter). So far, I haven't found a way TO map it a specific drive letter. But that's another story.
Is there a way to do this in VBA? Perhaps there is some add-in or something I'd need? :confused:
I've only known mapped drives (S:\, L:\, etc.) and UNC addresses (I think I have that right - \\server\folder) to use.
Pseudocode:
Code:
Sub Main
SaveFile "processingLog.txt"
End Sub
Sub SaveFile (FileToSave As String)
Dim folderLocation As String
'What it would look like if the network location could be mapped to a specific drive letter.
'Otherwise, what would it look like if the folder location is under My Network Places???
folderLocation = "L:\"
Application.Save folderLocation & "\" & FileToSave
End Sub
Any help would greatly help this project, and my stress level! :eek:
Many many thanks!
Dave
Re: Connect to/Reference a network folder?
if you want a dialog for users to pick a folder on the network you can use browseforfolder, starting at network locations
vb Code:
Set sh = CreateObject("shell.application")
Set fold = sh.BrowseForFolder(0, "Select a folder, NOT a file", &H4000, 18)
change parameters if needed, but should be correct for what you ask
fold will be a folder object, the default property is the folder title, but the full unc path can be returned from fold.self.path