Full path name for the GetOpenFileName

HunterN

Active Member
Joined
Mar 19, 2002
Messages
479
Hi,

I know how to use the GetOpenFilename that displays a dialog box for
the user to choose a file to open. What I want to know is this: can you
specify the full path so that the dialog box opens only in a certain directory?

This is what I have, but it does not seem to work. It only opens the My Documents directory.


myPath = ThisWorkbook.Path
UF = Application.GetOpenFilename(FileFilter:=myPath & "\Old Supps\" & "Text Files(*.txt),*.txt", _
Title:="Text Files to Open")

Thanks,
Nancy
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Nancy

The FileFilter argument is for filtering files.

If you want to use a particular directory try using ChDir.
Code:
ChDir myPath & "\Old Supps\"
 
Upvote 0
I sorry - but where do I put the change directory command?

ChDir myPath & "\Old Supps\"

Inside the GetOpenFilename or before I execute this Open Dialog box?

Nancy
 
Upvote 0
Nancy

Put it before GetOpenFilename.
Code:
ChDir myPath & "\Old Supps\" 
 UF = Application.GetOpenFilename(FileFilter:="Text Files(*.txt),*.txt", _
Title:="Text Files to Open")
 
Upvote 0
I put in the code above the OpenFilename line, and it still doesn't change anything. It still opens up in My Documents area
:confused:

Nancy
 
Upvote 0
Nancy

Did you also include the code for setting the value of mypath?

Are you on a network?
 
Upvote 0
Yes to setting the code for myPath
It equals "H:\Public Test"


and Yes to am I on a network!

So does that matter?

Nancy
 
Upvote 0

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

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