Dir = Select Directory

     

  • Enables to select a existing directory in particular path
  •  

    Private Sub CommandButton1_Click()
    Create variable for file name
    Dim filename As String
    Assign path to variable
    filename = Dir("E:\sales")
    End Sub

     

    Download The Workbook

     

     

    Curdir = Current Directory Path

     

  • It denotes about current directory path
  • Private Sub CommandButton1_Click()
    Range("A1").Value = CurDir
    MsgBox CurDir
    End Sub

     

    Download The Workbook

    FileLen - - File Length

     

  • It denotes about length of file
  • Private Sub CommandButton1_Click()
    'first create a note pad in E drive
    'denotes file length in bytes

    MsgBox FileLen("E:\Sales.txt")
    End Sub

    Download The Workbook

     

     

    MKDir - - Make Directory

     

    Private Sub CommandButton1_Click()
    'Create Directory\Folder in F Drive
    MkDir ("F:\sales")
    End Sub

     

    Download The Workbook

     

     

    Kill - Delete Files

     

    Private Sub CommandButton1_Click()
    'Delete all files in a directory
    Kill "F:\sales\*.txt"
    End Sub

     

    Download The Workbook

     

     

    Private Sub CommandButton1_Click()
    Dim source As String
    source = "d:\abc"
    'Delete text document in source path
    MsgBox source & "\" & "*.txt"
    Kill source & "\" & "*.txt"
    End Sub

     

    Download The Workbook

     

    FiledateTime - Date of File Created\Last Modified

     

    Private Sub CommandButton1_Click()
    Dim j As String
    j = CurDir
    'returns date of created or last modified
    MsgBox FileDateTime(j)
    End Sub

     

    Download The Workbook

     

    Chdir - Changes the Current Directory

     

    Private Sub CommandButton1_Click()
    'it changes the current directory
    ChDir "D:\sales"
    End Sub

     

    Download The Workbook

     

    Chdrive - Changes the drive

     

    Private Sub CommandButton1_Click()
    ChDrive "F:"
    End Sub

     

    Download The Workbook

     

    FileCopy - Copies from Source to Destination

     

    Private Sub CommandButton1_Click()
    FileCopy "E:\sales\abc.txt", "F:\sales\abc.txt"
    End Sub

     

    Download The Workbook

     

    Kill - Delete a File from a source

     

    Private Sub CommandButton1_Click()
    Kill ("D:\sales.txt")
    End Sub

    Download The Workbook

    RmDir - Remove Directory

     

     

    Private Sub CommandButton1_Click()
    RmDir "E:\Sales"
    End Sub

     

    Download The Workbook

     

     

     

     

    GetOpen File Name Method

     

     

    Private Sub CommandButton1_Click()
    Dim openfile As String
    openfile = Application.GetOpenFilename()
    End Sub

     

    Download The Workbook