Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


BrowseForFile

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1575
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> BrowseForFile
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 BrowseForFile - 11/4/2004 11:06:09 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Hiya,

I am familiar with the BrowseForFolder, but i am looking for the BrowseForFile (or similar).

      

Anyone ideas?

Thx [8)]

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com
 
 
Post #: 1
 
 Re: BrowseForFile - 11/5/2004 12:28:19 AM   
  mbouchard


Posts: 1863
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
I forget when I got this script, but it uses IE to browse for a file.


      

(in reply to Snipah)
 
 
Post #: 2
 
 Re: BrowseForFile - 11/5/2004 12:45:34 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Thx man, it works as i hoped... :D

(in reply to Snipah)
 
 
Post #: 3
 
 Re: BrowseForFile - 11/5/2004 9:05:34 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
This i found later:


      

(in reply to Snipah)
 
 
Post #: 4
 
 Re: BrowseForFile - 11/7/2004 3:05:08 PM   
  Res

 

Posts: 2
Score: 0
Joined: 11/7/2004
From: USA
Status: offline
Here is a VBS file that creates a version the the "browse for folder" dialog box that will display every folder in all drives, and show every file in any given folder, when that folder is selected.

'*************************************************************************************

Const WINDOW_HANDLE = 0
Const BIF_BROWSEINCLUDEFILES = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select Any Folder or File:", BIF_BROWSEINCLUDEFILES, "C:\ ")
Set objFolder.SubFolder = objFolder & "*\ "
Set objFile = objFolder.SubFolder & "* "
Set objFile.Extension = objFile & ".*"
Set objFile.Path = objFolder.SubFolder & "*" & objFile.Extension
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objPath & "'")
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objName & "'")
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objFile & "'")
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objFile.Name & "'")
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objFile.Path & "'")
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objFile.Extension & "'")
For Each objFile in colFiles
Wscript.Echo "Path: " & objFile.Path
Wscript.Echo "Name: " & objFile.Name
Next

'**********************************************************************************

Hope this helps! Fell free to contact me if you have any questions, good luck.

(in reply to Snipah)
 
 
Post #: 5
 
 Re: BrowseForFile - 11/17/2004 12:34:03 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline

      

in this case if you select a file (not a folder) from the desktop, then RET.TITLE = empty

Who can help with resolving this?


:( [sad face]

(in reply to Snipah)
 
 
Post #: 6
 
 Re: BrowseForFile - 11/17/2004 7:36:01 AM   
  mbouchard


Posts: 1863
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
Snipah,

Remove the on error resume next and you will see that it is giving you an error. Not really sure why as of yet, but am looking around.

(in reply to Snipah)
 
 
Post #: 7
 
 Re: BrowseForFile - 11/17/2004 2:36:02 PM   
  jbuttery

 

Posts: 24
Score: 0
Joined: 11/3/2004
From:
Status: offline
Res:
Looks mighty clean, but I'm a rookie and line 4 that begins
Set objFolder
gives me a file/path error (like an old basic 75/76 error). Any clues appreciated.
Jim

(in reply to Snipah)
 
 
Post #: 8
 
 Re: BrowseForFile - 11/17/2004 9:01:24 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
quote:
Originally posted by jbuttery

Res:
Looks mighty clean, but I'm a rookie and line 4 that begins
Set objFolder
gives me a file/path error (like an old basic 75/76 error). Any clues appreciated.
Jim



remove the Const en fill those in where they belong, that might help, it worked for me too.

(in reply to Snipah)
 
 
Post #: 9
 
 Re: BrowseForFile - 11/17/2004 9:17:04 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
quote:
Originally posted by mbouchard

Snipah,

Remove the on error resume next and you will see that it is giving you an error. Not really sure why as of yet, but am looking around.



Error line: Set Ret = ShellApp.BrowseForFolder(0, "Choose a file or folder", 16384)
Char: 1
Error: Invallid Procedure call or argument
Code: 800A0005
Source: Microsoft VBScript runtime error

(in reply to Snipah)
 
 
Post #: 10
 
 Re: BrowseForFile - 11/17/2004 11:21:26 PM   
  mbouchard


Posts: 1863
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
you need this line to get it working.

Set ShellApp = CreateObject("Shell.Application")

(in reply to Snipah)
 
 
Post #: 11
 
 Re: BrowseForFile - 11/17/2004 11:33:59 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
quote:
Originally posted by mbouchard

you need this line to get it working.

Set ShellApp = CreateObject("Shell.Application")



I have that allready

      

(in reply to Snipah)
 
 
Post #: 12
 
 RE: Re: BrowseForFile - 3/14/2006 3:11:11 PM   
  DiGiTAL.SkReAM


Posts: 1159
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Sorry for ressurrecting such an old topic, but I was searching for a file browsing hack for vbscript, and this was all I found.
So... I dug a bit deeper, even went over to other languages, until I found the following little snippet and figured that I'd post it here just in case someone else could use it - especially since this topic/thread was never successfully answered/solved.
NOTE : This works on WinXP, and I think it would work on Windows 2000 - if the .NET framework was installed.  Dunno, since I don't have any Win2000 boxen just laying around for testing.


      

And here's a screenshot of the code in action.  As you can see, it is the normal windows "Open File" dialog box.




Thumbnail Image


Attachment (1)

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to Snipah)
 
 
Post #: 13
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> BrowseForFile Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts