Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Muk Muk is offline
external usenet poster
 
Posts: 10
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM
Open File Dialog Filter Nigel Excel Programming 6 March 23rd 05 06:24 PM


All times are GMT +1. The time now is 06:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"