Application.GetOpenFilename

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

How do I get this code to look in a certain directory

Application.GetOpenFilename

Directory name

ward5

Thanksin advance

Greg
 
One way for mapped drives (assigned to letters):

Option Explicit
Sub testme()

Dim myFolder As String
Dim myFileName As Variant
Dim ExistingFolder As String

myFolder = "C:\my documents\excel\test"

ExistingFolder = CurDir

ChDrive myFolder
ChDir myFolder

myFileName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

ChDrive ExistingFolder
ChDir ExistingFolder

If myFileName = False Then
'do nothing
Else
MsgBox myFileName
'and the rest of your code
End If

End Sub
 
Dim s
ChDir "C:\Folder\folder2\folder you want"
s = Application.GetOpenFilename

tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top