Have user select file to open

GeneralShamu

Board Regular
Joined
Jul 6, 2007
Messages
127
I am writing code that requires data from another workbook. Instead of hardcoding the directory and filename (which changes daily), how can I have the code prompt the user to do this for me?

I want to open the file with:
links updated
read-only

Also, is there a way to have an initial directory that appears so the user need not go through a dozen directories every time to get to the file?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
This may help...

Code:
Sub test()
Dim SaveDriveDir As String
Dim TheFileName As Variant
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\Users\James\Documents\ExcelChest"
TheFileName = Application.GetOpenFilename(FileFilter:="Excel Files *.xls* (*.xls*),")

' "your code here"

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub
 
Upvote 0
How can I get the box that opens to prompt the user for a file to say something in the top left telling them what to do?

In my code for prompting the user to select a directory there is a line:
.Title = "..."
 
Upvote 0

Forum statistics

Threads
1,226,223
Messages
6,189,719
Members
453,566
Latest member
ariestattle

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