Using UserForms to access directories

barbicanboy

New Member
Joined
Sep 5, 2006
Messages
1
Hello,
I am pretty new to writing macros but have built something that seems pretty robust (My fingers are crossed it continues to work). As I hope it will work over time I would like to give the user the functionality to pick a file from the directory using a UserForm.
I have no idea how to do this and am unable to find anything in Bills VBA and Macros book or on the net.
Please help!
Peter
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
Good afternoon barbicanboy

Use the GetSaveAsFilename or GetOpenFilename (whether you are saving or opening a file). The example below outlines how to use it - without saving anything, the path and filenames are just dumped into the variables A and B.

Code:
Sub test()
a = Application.GetSaveAsFilename(fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
b = Application.GetOpenFilename(fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
MsgBox "Save As : " & a & Chr(13) & "File Open : " & b
End Sub

HTH

DominicB
 

Forum statistics

Threads
1,141,728
Messages
5,708,137
Members
421,549
Latest member
Dtcfire

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top