Want to become an expert in VBA? So this is the right place for you. This blog mainly focus on teaching how to apply Visual Basic for Microsoft Excel. So improve the functionality of your excel workbooks with the aid of this blog. Also ask any questions you have regarding MS Excel and applying VBA. We are happy to assist you.

Browse file and put path+name and name in two labels

Dim strFile As String
strFile = Application.GetOpenFilename("Excel workbooks,*.xls*")
If strFile = "False" Then
    ' if the user clicked Cancel
    'Here nothing will happen
Else
    'If the user selected a file; both its path and name is in strFile
    'So we store it in lable caption. you can set visibility of lable to false
    lblFromFilePath.Caption = strFile
    Dim WrdArray() As String
    WrdArray() = Split(strFile, "\")
    'here it will show the file name
    lblFromFile.Caption = WrdArray(UBound(WrdArray()))
End If

You can use below line to browse any type of file.

strFile = Application.GetOpenFilename()

Contact Form

Name

Email *

Message *

Popular Posts