ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open the OpenFiles window (https://www.excelbanter.com/excel-programming/375950-open-openfiles-window.html)

steven

Open the OpenFiles window
 
I would like to automate the file open box/window. My code is:

On the Before Double-Click of the sheet:
------------------------------
Dim vChDir as String
vChDir = ActiveCell.Value
ChDrive Mid(vChDir,1,2)
ChDir vChDir
------------------------------
I tried SendKeys ("%FO") ... but that does not work.

How do you open the File/Open box?

Thank you for your help.

Steven




Ron de Bruin

Open the OpenFiles window
 
Hi Steven

Use GetOpenFilename

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



"Steven" wrote in message ...
I would like to automate the file open box/window. My code is:

On the Before Double-Click of the sheet:
------------------------------
Dim vChDir as String
vChDir = ActiveCell.Value
ChDrive Mid(vChDir,1,2)
ChDir vChDir
------------------------------
I tried SendKeys ("%FO") ... but that does not work.

How do you open the File/Open box?

Thank you for your help.

Steven






Bob Phillips

Open the OpenFiles window
 
Look at GetOpenFilename in VBA help.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Steven" wrote in message
...
I would like to automate the file open box/window. My code is:

On the Before Double-Click of the sheet:
------------------------------
Dim vChDir as String
vChDir = ActiveCell.Value
ChDrive Mid(vChDir,1,2)
ChDir vChDir
------------------------------
I tried SendKeys ("%FO") ... but that does not work.

How do you open the File/Open box?

Thank you for your help.

Steven







All times are GMT +1. The time now is 03:11 AM.

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