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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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
Back
Top