|
-
June 23rd, 2009, 11:57 AM
#1
open a folder and select a file
hi,
i need know how can i open a folder and select a file that is inside of that folder
like windows does when we choose a option to locate a shorcut file
thanks a lot for your help
-
June 23rd, 2009, 01:34 PM
#2
Re: open a folder and select a file
You could use the command line switches in the explorer. Something like this should work
Code:
Dim filePath As String
filePath = "C:\Folder\FileName.txt"
Shell "Explorer /select," & Chr(34) & filePath & Chr(34), vbMaximizedFocus
-
June 24th, 2009, 10:18 AM
#3
Re: open a folder and select a file
No, I think what you seek is the CommonDialog control.
Add 'Microsoft CommonDialog Control 6.0' to your toolbox and put one on your form.
It allows to create a FileOpen dialog like windows uses to allow for the selection of a file somewhere on a drive.
If you need to know more details, CommonDialog is described in the VB online manual.
The most simple usage:
Put a CommonDialog on a form. Name it "cdlg"
In a button put the code: cdlg.ShowOpen to see if that's what you wanted.
You can walk through the folders and select a file, and after clicking ok it returns to your calling routine and cdlg.FileName contains the selected filename.
Very easy.
-
June 24th, 2009, 01:17 PM
#4
Re: open a folder and select a file
Duh!
I thought OP was talking about the select. But yes I agree, what he needs is a Common Dialog control which can be added to the control toolbox using the above procedure mentioned in post # 3.
-
June 24th, 2009, 03:29 PM
#5
Re: open a folder and select a file
You can also set the initial directory and one or more filters via code before you call the show open method. This way if you want them to be able to browse images only you can filter by image type or set of image types using wildcards. e.g. *.jpg *.bmp on so on
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|