GetOpenFilename

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to set the “GetOpenFilename†command to start in a specific
directory?

NameOfFile = Application _
.GetOpenFilename("Excel Files (*.xls), *.xls")
 
Hi

Try this

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:/Chrysant"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")
If FName <> False Then
Set wb = Workbooks.Open(FName)
MsgBox "your code"
wb.Close
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub
 
Ron's method is probably best, but if you want some more pain and suffering
in your life, it looks like the FileDialog method in Office 10 / Office XP
would do this, too :)

James Cox
 
Thank You

Dan

James Cox said:
Ron's method is probably best, but if you want some more pain and suffering
in your life, it looks like the FileDialog method in Office 10 / Office XP
would do this, too :)

James Cox
 
Thank You
Dan

Ron de Bruin said:
Hi

Try this

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:/Chrysant"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")
If FName <> False Then
Set wb = Workbooks.Open(FName)
MsgBox "your code"
wb.Close
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub
 

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