-
Browse File Dialog in Excel VBA
In Excel file, if you are doing any folder operations or trying to read content from another text,xlsx, csv file. It is better to use this file dialog box rather than manually typing the file name with path.
It would reduce the typing errors and also the file path will be exact as how it is in the system.
Lets see how to invoke it from a VBA code and get the file path directly.
1234567891011121314151617181920212223Sub Choose_File()Dim sSh As WorksheetDim filedialog As Office.FileDialog, txtFileNameSet filedialog = Application.FileDialog(msoFileDialogFilePicker)Set sSh = ThisWorkbook.Sheets("Settings")txtFileName = ""With filedialog.AllowMultiSelect = False.Title = "Choose File(s)".Filters.Add "Excel", "*.xls*".Filters.Add "Csv", "*.csv*".Filters.Add "Text", "*.txt*".Filters.Add "All", "*.*"If .Show = True ThentxtFileName = .SelectedItems(1)End IfEnd WithsSh.Cells(1, 2) = txtFileNamesSh.Columns("B:B").AutoFitEnd Sub
Rename the sheet name from “Settings” to any worksheet name as it is in your Excel workbook.Previous Post: Excel VBA – Copy Sheet To Another Workbook
Next Post: Enable Disable Excel Command-Bar Options
VBA File Open Dialog Box
Popular Posts
Recent Posts
Similar Pages
Popular Tags
- Block Apps in FaceBook print screen Excel Countif Record Macro Timer in Excel Task Manager VCF HTML Table Import Data Thumbnails Text to Speech TTS Candy Crush C++ Programing Machine learning AI bulk email Excel VBA vba color index vba color codes Android social media Twitter Google+ Google Adsense Tips bitcoin Calendar in Excel outlook vba mass email Data Mining Excel Macro Facebook WhatsApp python Wordpress