This code:

Set oShell = CreateObject("Shell.Application")

set oFolder = oShell.BrowseForFolder(0,"Select poem",BIF_BROWSEINCLUDEFILES
+ 1,5)


Gives This Error
the system cannot find the file specified

Any thoughts???

Works great if I select a folder, dies if I select a file. works OK in VB6,
fails in VBScript

A

Re: browseforfolder to find file by Richard

Richard
Mon Feb 26 22:21:07 CST 2007

Alan Gillott wrote:

> This code:
>
> Set oShell = CreateObject("Shell.Application")
>
> set oFolder = oShell.BrowseForFolder(0,"Select
> poem",BIF_BROWSEINCLUDEFILES + 1,5)
>
>
> Gives This Error
> the system cannot find the file specified
>
> Any thoughts???
>
> Works great if I select a folder, dies if I select a file. works OK in
> VB6, fails in VBScript
>

First, you must assign the value &H4000 to BIF_BROWSEINCLUDEFILES. Next, the
shell application provides a wrapper for the shBrowseForFolder API. I a
believe this option allows you to view files in the folders, but does not
allow you to select files. At least, when I use the API I am not able to
select files. I had to use completely different methods to select files.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--



Re: browseforfolder to find file by mayayana

mayayana
Mon Feb 26 22:31:41 CST 2007

I don't get what "+ 1,5" is, but assuming
BIF_BROWSEINCLUDEFILES is &H4000
it should work on some systems. It works on
Win98. But I don't think it works on XP and
maybe not on ME.

If you want to browse for files and have it work on
any system, you can use this:

---------------------------------------
s = ChooseFile()
MsgBox s

Function ChooseFile()
On Error Resume Next
Dim Q2, sRet
Q2 = chr(34)
ChooseFile = ""
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = False
IE.Navigate("about:blank")
Do Until IE.ReadyState = 4
Loop

IE.Document.Write "<HTML><BODY><INPUT ID=" & Q2 & "Fil" & Q2 & "Type=" &
Q2 & "file" & Q2 & "></BODY></HTML>"
With IE.Document.all.Fil
.focus
.click
sRet = .value
End With
IE.Quit
Set IE = Nothing
ChooseFile = sRet
End Function
--------------------------------

> This code:
>
> Set oShell = CreateObject("Shell.Application")
>
> set oFolder = oShell.BrowseForFolder(0,"Select
poem",BIF_BROWSEINCLUDEFILES
> + 1,5)
>
>
> Gives This Error
> the system cannot find the file specified
>
> Any thoughts???
>
> Works great if I select a folder, dies if I select a file. works OK in
VB6,
> fails in VBScript
>
> A
>
>



Re: browseforfolder to find file by Ayush

Ayush
Tue Feb 27 10:09:32 CST 2007

Replied to [mayayana]s message :
> But I don't think it works on XP and
> maybe not on ME.

Yup, it doesn't work here on XP Sp2


Good Luck, Ayush.
--
Scripting Solutions Center : http://snipurl.com/Scripting_Solutions

Re: browseforfolder to find file by TDM

TDM
Tue Feb 27 12:40:18 CST 2007


"mayayana" <mayayana1a@mindspring.com> wrote in message
news:NuOEh.6971$tD2.3922@newsread1.news.pas.earthlink.net...
> I don't get what "+ 1,5" is, but assuming
> BIF_BROWSEINCLUDEFILES is &H4000
> it should work on some systems. It works on
> Win98. But I don't think it works on XP and
> maybe not on ME.
>

here is a function I use that works on XP, have not tested it on
anything else.

The function returns the Full path, pass in your starting point
like "C:\temp" etc.

Function browseForFile(strStartPath)
' This function returns the file name via the Browse for file box.
'
Dim objDialog
Dim iRtn

Set objDialog = CreateObject("UserAccounts.CommonDialog")

With objDialog
.Filter = "All Files|*.*"
.FilterIndex = 1
.InitialDir = strStartPath
iRtn = .ShowOpen
If iRtn = 0 Then
browseForFile = ""
Else
browseForFile = .FileName
End If
End With

End Function


TDM



Re: browseforfolder to find file by mayayana

mayayana
Tue Feb 27 13:19:07 CST 2007

>
> here is a function I use that works on XP, have not tested it on
> anything else.

That's XP only.



Re: browseforfolder to find file by TDM

TDM
Tue Feb 27 15:23:42 CST 2007


"mayayana" <mayayana1a@mindspring.com> wrote in message
news:Lu%Eh.6594$_73.1888@newsread2.news.pas.earthlink.net...
> >
>> here is a function I use that works on XP, have not tested it on
>> anything else.
>
> That's XP only.
>
>

Thanks for the info.


TDM