+ Reply to Thread
Results 1 to 6 of 6

Macro to open specific folder

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-23-2013
    Location
    India
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    227

    Macro to open specific folder

    Hello, how can i open a specific folder using a single click on a button?

    For example: i want to open this path: U:\A. Sampl1\B. Sample2

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Macro to open specific folder

    hi,

    Check this (paste it into standard module)
    Option Explicit
     
    Sub Open_Explorer()
        Dim stFolder As String
         
        stFolder = "c:\Temp"
         
        If Len(Dir(stFolder, vbDirectory)) <> 0 Then
            Shell "Explorer.exe /n,/e," & stFolder, vbNormalFocus
        Else
            MsgBox "The directory does not exist!", vbCritical
        End If
         
    End Sub
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to open specific folder

    Maybe:

    Sub siobeh()
    Dim Yourfolder As String
    
    Yourfolder = "U:\A Sample1\B Sample2\"
    ActiveWorkbook.FollowHyperlink Yourfolder, NewWindow:=True
    
    End Sub

  4. #4
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Macro to open specific folder

    Good way JOHN H. DAVIS but for me there is one little problem - everytime code is running user will have to accept security window because Hiperlinks are not safe in Excel meaning

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to open specific folder

    You're right MaczaQ. Could not figure a way around. Looks like your solution is better because it avoids that.

  6. #6
    Forum Contributor
    Join Date
    04-23-2013
    Location
    India
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    227

    Re: Macro to open specific folder

    It works! Thanks MaczaQ and John! Perfect!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1