Results 1 to 2 of 2

Thread: [RESOLVED] Connect to/Reference a network folder?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    2

    Resolved [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

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. Set sh = CreateObject("shell.application")
    2. 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
  •  



Click Here to Expand Forum to Full Width