ExcelBanter

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

wtpcomplab

GetOpenFilename
 
Is there a way to set the €śGetOpenFilename€ť command to start in a specific
directory?

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

Ron de Bruin

GetOpenFilename
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"wtpcomplab" wrote in message
...
Is there a way to set the "GetOpenFilename" command to start in a specific
directory?

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




James Cox[_2_]

GetOpenFilename
 
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
"wtpcomplab" wrote in message
...
Is there a way to set the "GetOpenFilename" command to start in a specific
directory?

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




wtpcomplab

GetOpenFilename
 
Thank You

Dan

"James Cox" wrote:

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
"wtpcomplab" wrote in message
...
Is there a way to set the "GetOpenFilename" command to start in a specific
directory?

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





wtpcomplab

GetOpenFilename
 
Thank You
Dan

"Ron de Bruin" wrote:

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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"wtpcomplab" wrote in message
...
Is there a way to set the "GetOpenFilename" command to start in a specific
directory?

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






All times are GMT +1. The time now is 07:04 PM.

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