|
-
Oct 5th, 2011, 05:34 PM
#1
Thread Starter
New Member
[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? 
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! 
Many many thanks!
Dave
-
Oct 6th, 2011, 05:38 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|