Results 1 to 59 of 59

VB code Get 2 latest file names from Directory

Threaded View

  1. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: VB code Get 2 latest file names from Directory

    Hi..

    Something like this..

    Assumes it is Excel files you're looking for..

    Private Sub CheckBox1_Click()
        If CheckBox1.Value = True Then
            strFile = [K1]
            Z = Filter(Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & strFile & "*.xls"" /s/b/O-D").stdout.readall, vbCrLf), ":")
            [L1] = Z(0): [M1] = Z(1)
            CheckBox1.Caption = "TRUE"
            Else
            [L1] = "": [M1] = ""
            CheckBox1.Caption = "FALSE"
        End If
    End Sub
    
    Private Sub CheckBox2_Click()
     If CheckBox2.Value = True Then
            strFile = [K2]
            Z = Filter(Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & strFile & "*.xls"" /s/b/O-D").stdout.readall, vbCrLf), ":")
            [L2] = Z(0): [M2] = Z(1)
            CheckBox2.Caption = "TRUE"
            Else
            [L2] = "": [M2] = ""
            CheckBox2.Caption = "FALSE"
        End If
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 11-28-2013, 05:20 PM
  2. Need VBA code to search file in directory and sub-directory and show result
    By johnchencanada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2012, 11:13 PM
  3. [SOLVED] Reading in files from directory......does this code also alphabetize the file names
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-24-2012, 08:20 AM
  4. Import file size and file names from a directory
    By zahid in forum Excel General
    Replies: 1
    Last Post: 02-07-2006, 09:35 AM
  5. Getting file names in a directory
    By John in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2005, 12:06 PM

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