Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Programmer1974 (Programmer) (OP)
5 Jan 05 10:44
Hello all!

I'm writting an HTML document where part of the functionality lets the user browse for a folder, and in another place to browse for a file. After searching through many threads, I've found that the following code works for the folders:

Set objFolder = objShell.BrowseForFolder(0, "Select a folder:", &H0)

and the following code works for files:

<input type="file" name="myFile">

However, these two methods display different dialogue boxes, and I'm trying to achive continuity. The BrowseForFolder function does not work when selecting files, and I can't find any HTML code to return a folder. Does anyone know how to do either of these two things, or yet a third option that will achive both? I am espescially interested in the vbScript method because I will be able to use it in non-html programs.

Thanks all for your help.
Helpful Member!  mrmovie (TechnicalUser)
5 Jan 05 10:47
does this help?

Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

ObjFSO.Filter = "VBScripts|*.vbs|Text Documents|*.txt|All Files|*.*"

ObjFSO.FilterIndex = 3

ObjFSO.InitialDir = "c:\myscripts"

InitFSO = ObjFSO.ShowOpen

If InitFSO = False Then
    Wscript.Echo "Script Error: Please select a file!"
    Wscript.Quit
Else
    Wscript.Echo "You selected the file: " & ObjFSO.FileName
End If
mrmovie (TechnicalUser)
5 Jan 05 10:50
or

set oFO = CreateObject("SAFRCFileDlg.FileOpen")
' exposed in safrcdlg.dll
oFO.OpenFileOpenDlg
wscript.echo oFO.FileName
Programmer1974 (Programmer) (OP)
5 Jan 05 12:21
Thanks for the input, but I get the following error:

Error: ActiveX component can't create object: 'SAFRCFileDlg.FileOpen'

which probably means I need to download the appropriate dlls. I do now know if that will be acceptable to our LAN team, so if there are other alternatives, I would be appriciative to hear them!

Thanks
mrmovie (TechnicalUser)
6 Jan 05 6:20
hi 1974, im afraid thats the only details ive got.

have you tried my first post??? this works for me and doesnt require an additional dll...
Helpful Member!  tsuji (TechnicalUser)
6 Jan 05 8:13
Hello Programmer1984,

[1] Safrcfiledlg.fileopen is with xp.

[2] For simulation using file selection using input, type="file" msie browser, you can dynamically make htm file for systematic use by calling a pre-fabricated block of code. That is the cheapest and most probably useable for windows platform. You can mimic or use one from jsware:
    http://www.jsware.net/jsware/zips/claspak.zip
in particular, the fileopen.vbs.

[3] If it is more a developers/technical environment where you think most get vb package installed (a commercial visual studio or ms free vb5 editor) then you have all the necessary licence to use comdialog.ocx. With it installed, you can do something neat, like this.

CODE

set ocomdlg=createobject("mscomdlg.commondialog")
with ocomdlg
    .dialogtitle="select a file"
    .initdir="d:\test"
    .filter="All files (*.*)"
    .maxfilesize=10000    'filter filesize
    .showopen
end with
filespec=ocomdlg.filename
wscript.echo filespec
These two are the solution to get scripter by I would prefer.

regards - tsuji
Programmer1974 (Programmer) (OP)
6 Jan 05 9:32
Thanks all for the help, but I still havn't quite found what I'm looking for.

mrmovie, I do get an error with your first example, which is that activeX can't create the object. I'll keep trying though.

tsuji, the vbScript that you've provided from the download was cool, but it's basically the same thing I have above where it uses the HTML: <input type="file" name="myFile">. I did provide me with some ideas for other scripts though.

Also, none of us have VB Studios, or anything like that. We're mostly a mainframe COBOL shop, so my options are limited to straight VB/HTML code. I may venture in to JScript if all else fails.

Please let me know if there are more ideas out there! Thanks again!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close