Be the first user to complete this post

  • 0
Add to List

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

This tutorial will teach you how to Open a Excel File using Another Excel File using Browse Option. We will be using Application.GetOpenFile() function to accomplish 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 provide any filter if you want to select any type of file as attachment

Complete 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
Sheet1.Range("G5").Value = strFileToOpen
Workbooks.Open Filename:=strFileToOpen
End If
End Sub

Browse File - 1
Browse File - 2

Also Read:

  1. VBA-Excel: Copy/Paste data - Copy the data from a call and paste it to another cell
  2. VBA-Excel: Add/Insert multiple objects from a folder in an Excel Document.
  3. VBA Excel – Looping Through a Range of Cells
  4. VBA-Excel: Get the names of all WorkSheets in a Excel (WorkBook)
  5. Excel-VBA : Prevent Changing the WorkSheet Name
  6. Password Protection to Your Macro Code
  7. VBA-Excel: Clear data from Excel Sheet(WorkSheet)
  8. FileSystemObject:OpenTextFile Method