Common File Operations Simplified : File « File Path « VBA / Excel / Access / Word






Common File Operations Simplified

 
Sub TestGetFile() 
    Dim nIndex As Integer 
    Dim sFile As String 
    sFile = GetExcelFile("Testing GetExcelFile Function") 
    If sFile = "False" Then 
        Debug.Print "No file selected." 
        Exit Sub 
    End If 
    Debug.Print sFile 
End Sub 
Function GetExcelFile(sTitle As String) As String 
    Dim sFilter As String 
    Dim bMultiSelect As Boolean 
    sFilter = "Workbooks (*.xls), *.xls" 
    bMultiSelect = False 
    GetExcelFile = Application.GetOpenFilename(FileFilter:=sFilter, _ 
        Title:=sTitle, MultiSelect:=bMultiSelect) 
End Function 

 








Related examples in the same category

1.Does the specified file exist?
2.Check file existance
3.Gets the file name from the path.
4.List all files under application path
5.Select a folder
6.Select a location containing the files you want to list
7.processes multiple stored files
8.Use array to store a list of files