Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2005
    Posts
    6

    Question Unanswered: button to open a folder

    Hi there
    I have a form where it holds the details of clients and I want a button, that when clicked, opens up a folder e.g The ABC files, that contains various Word docs etc..All I want is for the button to just open the specified folder. Is there a way to do this as I can't seem to find one.
    Thanks
    ugive

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Here is an example for what you need
    Attached Files Attached Files

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    hammbakka has provided to you a means to access the file system using the Common Dialog Control. Here are a couple of other ways. One is by using Windows API functions and yet another utilizing the Microsoft Office 10.0 Object Library. Provided is a sample:

    Reference must be made to the Microsoft Office 10.0 Object Library


    .
    Attached Files Attached Files
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Nice CyberLynx - I've never played much with dialogs (never had the need) so that is interesting.

    One thing I didn't get - why set the reference and then late bind? Why not Dim dlg As FileDialog?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2003
    Posts
    1,487
    pootle....just habbit I quess.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  6. #6
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Some very good information her, but it you are not into APIs and don't know about references then perhaps it may be a little simpler to use the Shell command to open a given folder with explorer ?

    Code:
    Sub OpenExplorer()
    Dim x As Variant
    Const msgTitle As String = "Open Explorer"
    Const cExplorerPath As String = "C:\WINDOWS\EXPLORER.EXE"
    Const cExplorerSwitches As String = " /n,/e"
    Const cFilePath As String = "YourFilePath"
    
    On Error GoTo Error_Handler
    
    If Dir(cExplorerPath, vbDirectory) = "" Then
        MsgBox "Explorer Path '" & cExplorerPath & "' could not be found.", vbCritical, msgTitle
        x = Shell(cExplorerPath, vbNormalFocus)
    ElseIf Dir(cFilePath, vbDirectory) = "" Then
        MsgBox "Path '" & cFilePath & "' could not be found.", vbCritical, msgTitle
        x = Shell(cExplorerPath, vbNormalFocus)
    Else
        x = Shell(cExplorerPath & cExplorerSwitches & "," & cFilePath, vbNormalFocus)
    End If
    
    Exit Sub
    Error_Handler:
    
    MsgBox "An error has occured trying to open Explorer", vbCritical, msgTitle
    
    End Sub
    If you want to use this for different folders, then you will need past the path each time.

    Or is this too old hat ?

    MTB

Posting Permissions

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