ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.GetOpenFilename (https://www.excelbanter.com/excel-programming/323614-application-getopenfilename.html)

Greg[_19_]

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

Application.GetOpenFilename

Directory name

ward5

Thanksin advance

Greg



Dave Peterson[_5_]

Application.GetOpenFilename
 
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

Greg wrote:

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

Application.GetOpenFilename

Directory name

ward5

Thanksin advance

Greg


--

Dave Peterson

Greg[_19_]

Application.GetOpenFilename
 
Thanks once again

It is exactly what i want

Greg



Tim Williams

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

tim

"Greg" wrote in message
...
How do I get this code to look in a certain directory

Application.GetOpenFilename

Directory name

ward5

Thanksin advance

Greg





All times are GMT +1. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com