Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 6 of 6

Thread: Test and open a directory with explorer using vba

  1. #1
    Join Date
    31st March 2004
    Location
    Brazil
    Posts
    25

    Test and open a directory with explorer using vba

    Hi all,

    Using VBA, I need to open a directory using Explorer or Internet Explorer, but with a condition that if the directory doesn't exists, I will receive some kind of alert that will allow me to try a diferent path.

    Thx,

    Pacheco

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    25th January 2003
    Location
    Ístersund, Sweden
    Posts
    2,451

    Re: Test and open a directory with explorer using vba

    Pacheco,

    Do You want to open Explorer from Excel with a specific directory open?
    Kind regards,
    Dennis

    .NET & Excel | 2nd edition PED | MVP

  3. #3
    Join Date
    31st March 2004
    Location
    Brazil
    Posts
    25

    Re: Test and open a directory with explorer using vba

    Yes, I need to open a specific directory (e.g: c:\temp), but I also need to be able to determine if that directory exists (e.g: c:\temp\test -> error)

    I tried to use the shell command:

    Dim RetVal
    RetVal = Shell("C:\windows\explorer c:\temp", 1)

    But in that way I can┤t determine if that works or not.

    Thx for any hint,

    Pacheco

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    25th January 2003
    Location
    Ístersund, Sweden
    Posts
    2,451

    Re: Test and open a directory with explorer using vba

    Pacheco,

    Below You find an example:

    VB:
    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 
    
    
    Kind regards,
    Dennis

    .NET & Excel | 2nd edition PED | MVP

  5. #5
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Test and open a directory with explorer using vba

    Pacheco

    You can check for the existence of a directory (or file) using the Dir statement.

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    31st March 2004
    Location
    Brazil
    Posts
    25

    Re: Test and open a directory with explorer using vba

    Thx for your help, I will be able to finish my code now

    Pacheco

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Open all books in directory
    By CallMeJD in forum EXCEL HELP
    Replies: 1
    Last Post: December 3rd, 2005, 01:09
  2. Open Data Source directory
    By tlee in forum Excel and/or Word Help
    Replies: 5
    Last Post: September 8th, 2005, 00:56
  3. To open files from current directory
    By RWA in forum EXCEL HELP
    Replies: 2
    Last Post: September 1st, 2005, 22:56
  4. VBA to open Windows Explorer
    By royg1234 in forum EXCEL HELP
    Replies: 4
    Last Post: August 3rd, 2005, 07:33
  5. [Solved] Test Valid Directory Path
    By Bronsted in forum EXCEL HELP
    Replies: 5
    Last Post: August 12th, 2003, 05:40

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
  •  
porno