![]() |
Application.FileDialog(msoFileDialogOpen)
LS, from Excel with VBA using a UserForm I can display the files in a special directory, using: With Application.FileDialog(msoFileDialogOpen) ..InitialFileName = strPath & "\*" ..AllowMultiSelect = False ..Show End With How do I manage that from that FileDiaolog a file (.xls, .doc or .txt) can be opened? Doubleclick on the file gives no result. -- H.A. de Wilde ------------------------------------------------------------------------ H.A. de Wilde's Profile: http://www.excelforum.com/member.php...o&userid=30679 View this thread: http://www.excelforum.com/showthread...hreadid=548160 |
Application.FileDialog(msoFileDialogOpen)
This example use GetOpenFilename that can do the same and it is working in 97 and up
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 For multiselect do it like this Sub testing() Dim FName As Variant Dim N As Long FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", _ MultiSelect:=True) If IsArray(FName) Then For N = LBound(FName) To UBound(FName) Workbooks.Open (FName(N)) Next End If End Sub -- Regards Ron De Bruin http://www.rondebruin.nl "H.A. de Wilde" wrote in message news:H.A.de.Wilde.28ufsm_1149367203.8099@excelforu m-nospam.com... LS, from Excel with VBA using a UserForm I can display the files in a special directory, using: With Application.FileDialog(msoFileDialogOpen) InitialFileName = strPath & "\*" AllowMultiSelect = False Show End With How do I manage that from that FileDiaolog a file (.xls, .doc or .txt) can be opened? Doubleclick on the file gives no result. -- H.A. de Wilde ------------------------------------------------------------------------ H.A. de Wilde's Profile: http://www.excelforum.com/member.php...o&userid=30679 View this thread: http://www.excelforum.com/showthread...hreadid=548160 |
All times are GMT +1. The time now is 09:58 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com