Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Feb 2010
    Location
    Denver, CO
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open Explorer to a specified folder (AXP (2002) SP-1)

    I'm sure this is simple, but I cannot find this is my resources. How do I have Access code open Explorer to a specified folder? Can I use UNC format in specifying the folder?

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Open Explorer to a specified folder (AXP (2002) SP-1)

    Using hyperlink would be easiest way to do this. It depends where you are using this, for a control like a command button you'd use button's Hyperlink property. You can test this from Immediate window using Application FollowHyperlink method. Example:

    Application.FollowHyperlink "SERVERNAMEGLOBALSUBFOLDERFOLDERABC",,True

    This will work with any valid hyperlink address, including UNC as shown. For folder path, Windows Explorer will open. True argument specifies open in new window.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2010
    Location
    Denver, CO
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Explorer to a specified folder (AXP (2002) SP-1)

    Thanks for your response. I actually need to use code that will open Explorer to a folder at the end of a procedure. The folder could be one of several folders, depending upon certain variables in the procedure.

    Actually, I have a listbox filled with different datasets that can be exported to Excel or text files. Different lists are exported to different folders. I want Explorer to automagically open in the destination folder.

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Open Explorer to a specified folder (AXP (2002) SP-1)

    If that's the situation I'd use FollowHyperlink method. Here is a simple example (no error handling, etc) of sub that exports a table to a text file in specified folder, then opens folder using hyperlink:

    Public Sub ExportTextFile(ByVal strTbl As String, ByVal strPath As String)

    ' strTbl = name of table
    ' strPath = folder to export to (w/o "" at end)
    ' Export as generic delimited text file (no Export Spec specified as 2nd arg)
    ' Optional 5th arg HasFieldNames "True" first row will reflect field names

    DoCmd.TransferText acExportDelim, , strTbl, _
    strPath & "" & strTbl & ".txt", True

    ' Open folder:
    Application.FollowHyperlink strPath, , True

    End Sub

    Example of use (using Northwind.mdb Products table):

    ExportTextFile "Products","C:Program FilesMicrosoft OfficeOfficeSamples"

    This exports Products table to Samples folder, then opens same folder. This will work same way with network path, including UNC paths (as long as you provide valid folder name when running sub).

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •