![]() |
File Open Dilog Box with Filter
Hi!
I want take user's input for selection of file and for the same I am trying to open File open Dilog Box using the filters (i.e .dbf; .p3; .xls) for the input. I used to do like this but now I am not able to do with same CommonDialog1.Filename = ".P3" CommonDialog1.ShowOpen string1 = Len(CommonDialog1.FileTitle) temp1 = CommonDialog1.Filename dirpath = Mid(temp1, 1, Len(temp1) - string1 - 1) txt_ppath = dirpath txt_network = Left(CommonDialog1.FileTitle, 4) Will you help me how can I do this |
File Open Dilog Box with Filter
Muk,
I think you are thinking about VB proper, VBA is a little different. You need to use Application..GetOpenFilename( FileFilter, FilterIndex, Title, , MultiSelect) whe FileFilter = A string specifying file filtering criteria. [Optional Variant] ie "Text Files (*.txt),*.txt,Add-In Files (*.xla),*.xla," & _ "Visual Basic Files (*.bas; *.txt),*.bas;*.txt" If omitted, this argument defaults to "All Files (*.*),*.*". FilterIndex = Specifies the index numbers of the default file filtering criteria, from 1 to the number of filters specified in FileFilter. If this argument is omitted or greater than the number of filters present, the first file filter is used. [Optional Variant] Title = Specifies the title of the dialog box. If this argument is omitted, the title is "Open." [Optional Variant] MultiSelect = True to allow multiple file names to be selected. False to allow only one file name to be selected. The default value is False [Optional Variant] Returns the selected file name or the name entered by the user. The returned name may include a path specification. If MultiSelect is True, the return value is an array of the selected file names (even if only one filename is selected). Returns False if the user cancels the dialog box. This method may change the current drive or folder. Example dim vFileToOpen as variant vFileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If You can then open the file. -- Hope this helps Martin Fishlock Please do not forget to rate this reply. "Muk" wrote: Hi! I want take user's input for selection of file and for the same I am trying to open File open Dilog Box using the filters (i.e .dbf; .p3; .xls) for the input. I used to do like this but now I am not able to do with same CommonDialog1.Filename = ".P3" CommonDialog1.ShowOpen string1 = Len(CommonDialog1.FileTitle) temp1 = CommonDialog1.Filename dirpath = Mid(temp1, 1, Len(temp1) - string1 - 1) txt_ppath = dirpath txt_network = Left(CommonDialog1.FileTitle, 4) Will you help me how can I do this |
All times are GMT +1. The time now is 05:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com