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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Open Explorer to a specified folder (AXP (2002) SP-1)

    Author
    Topic
    #384777

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #661231

      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.

      • #661245

        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.

        • #661259

          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

    Viewing 0 reply threads
    Reply To: Open Explorer to a specified folder (AXP (2002) SP-1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: