Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Excel-VBA : Open a Excel File using Another Excel File using Browse Option.

This tuto­r­ial will teach you how to Open a Excel File using Another Excel File using Browse Option. We will be using Application.GetOpenFile() func­tion to accom­plish this.

NOTE: You can define any type file you want to , just set the proper filter.

FileFilter:=“Excel Files *.xls* (*.xls*) — to open Excel files

FileFilter:=“Excel Files *.txt* (*.txt*) — To open Text File

NOTE :Do not pro­vide any fil­ter if you want to select any type of file as attachment

Com­plete Code:

Sub browse()
    Dim FSO As Object
    Dim blnOpen
    strFileToOpen = Application.GetOpenFilename(Title:="Please choose a file to open", _
    FileFilter:="Excel Files *.xls* (*.xls*),")
    If strFileToOpen = False Then
      MsgBox "No file selected.", vbExclamation, "Sorry!"
      Exit Sub
    Else
        Sheet1.Range("G5").Value = strFileToOpen
        Workbooks.Open Filename:=strFileToOpen
    End If
End Sub

Browse File - 1

 

Browse File - 2

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: