4

I wonder how do I use this style to select a folder?

enter image description here

I ask this after finding the ability to search for files like this:

Set wShell=CreateObject("WScript.Shell")
Set oExec=wShell.Exec("mshta.exe ""about:<input type=file id=FILE><script>FILE.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>""")
sFileSelected = oExec.StdOut.ReadLine
If sFileSelected = "" Then
    WScript.Echo "Canceled"
Else
wscript.echo sFileSelected
End If

enter image description here

Humberto Freitas
  • 461
  • 1
  • 6
  • 21
  • 1
    Perhaps [this my answer](http://stackoverflow.com/a/28672540/3439404) could help... It's a basic small HTA sample opening either file or folder dialogue... – JosefZ May 30 '15 at 19:55
  • So I saw your post before asking, the problem is that this new style fits best in what I do and there is only one old style and even if I add a editbox could not do the same to generate an error when typing one invalid path. – Humberto Freitas May 31 '15 at 14:47
  • Yes, I see; found _a simple customization of the Win32 open file dialog that enables it to be used to select either a file or a folder_. Copyright (C) 2010 Scott Wisniewski; he says [It's free, and in the public domain. Use it as you see fit](http://stackoverflow.com/a/514368/3439404). HTH. – JosefZ May 31 '15 at 20:03
  • Unfortunately I need to be in .vbs... I looked above and saw that it is possible to add a editbox putting &H0211 however by placing one invalid path does not present any error... [http://pastebin.com/XjJP401X](http://pastebin.com/XjJP401X) – Humberto Freitas May 31 '15 at 20:53

1 Answers1

0

Try this:

Set chosenfolder = CreateObject("shell.application").BrowseForFolder(0,"Select a folder",0)
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
  • Thanks for answering my question, but I needed the window design was like the post. – Humberto Freitas Oct 26 '15 at 17:02
  • While this answer is probably correct and useful, it is preferred if you [include some explanation along with it](http://meta.stackexchange.com/q/114762/159034) to explain how it helps to solve the problem. This becomes especially useful in the future, if there is a change (possibly unrelated) that causes it to stop working and users need to understand how it once worked. – Kevin Brown-Silva Oct 30 '15 at 21:44