ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetOpenFilename Dialog default path (https://www.excelbanter.com/excel-programming/300368-getopenfilename-dialog-default-path.html)

Arthlan

GetOpenFilename Dialog default path
 
Hi

I'd like to display the open file dialog, but I'd like to default to the path that the workbook is in. I tried setting application.DefaultFilePath, but that didn't seem to help. I even tried opening and closing another file (quickly) in this path thinking it might stick -- it didn't

Is there any way to do this

Arthlan

Ron de Bruin

GetOpenFilename Dialog default path
 
Try this

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

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
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


"Arthlan" wrote in message ...
Hi,

I'd like to display the open file dialog, but I'd like to default to the path that the workbook is in. I tried setting

application.DefaultFilePath, but that didn't seem to help. I even tried opening and closing another file (quickly) in this path
thinking it might stick -- it didn't.

Is there any way to do this?

Arthlan





All times are GMT +1. The time now is 10:56 AM.

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