Reference for CommonDialog

Papyx Posted messages 307 Registration date   Status Member Last intervention   -  
Papyx Posted messages 307 Registration date   Status Member Last intervention   -
Hello,
What is the reference I need to check in Visual Basic to be able to use
CommonDialog in VBS or HTA programs?
Thank you

Configuration: Windows Vista / Firefox 33.0

4 answers

  1. cs_Le Pivert Posted messages 8437 Status Contributor 730
     
    Here is a file and folder search script:

    Const RETURNONLYFSDIRS = &H1 BIF_returnonlyfsdirs = &H0001 BIF_dontgobelowdomain = &H0002 BIF_editbox = &H0010 BIF_validate = &H0020 BIF_browseforcomputer = &H1000 Dim Title, Choice, vbCrlf, Task, ChoiceMsg Dim MyVar, MyInputbox Dim Path Dim WshShell, objDlg, oFolder, oShell Dim shell, item Set shell = WScript.CreateObject("Shell.Application") flag=BIF_returnonlyfsdirs Set WshShell = wscript.CreateObject("WScript.Shell") Title = "Search file and folder" vbCrlf = Chr(13) Task = Split("Search file,Search folder,Quit,",",") Do Choice = Inputbox("Enter the number of the task you want to perform :" & vbCrlf & vbCrlf & "1) Search file" & vbCrlf & "2) Search folder" & vbCrlf & "0) Quit", Title, "0") If Choice <> 0 Then On Error Resume Next Select Case Choice Case 1: sIniDir = "C:\Windows\*" sFilter = "All files (*.*)|*.*|Microsoft Word (*.doc;*.docx)|*.doc;*.docx|Adobe pdf (*.pdf)|*.pdf|Image files (*.gif;*.png;*jpg;*.bmp)|*.gif;*.png;*jpg;*.bmp|Html files (*.htm;*.html;*.mht)|*.htm;*.html;*.mht|" sTitle = "Search file path" rep = GetFileDlgEx(Replace(sIniDir,"\","\\"),sFilter,sTitle) Path=rep & vbcrlf & Len(rep) Path=InputBox("Copy to place the path in the clipboard", "Search file path", Path) Case 2 : Set oShell = CreateObject("Shell.Application") Set oFolder = oShell.BrowseForFolder(&H0&, "Choose a directory", RETURNONLYFSDIRS, "c:\") If oFolder is Nothing Then MsgBox "Operator abandoned",vbCritical Else Set oFolderItem = oFolder.Self Path=oFolderItem.path Path=InputBox("Copy to place the path in the clipboard", "Search folder path", Path) End If End Select On Error Goto 0 End If If Choice = 0 Then ChoiceMsg = MsgBox("Do you want to exit the application?", vbYesNoCancel, Title) If ChoiceMsg = vbYes Then WScript.quit End If Loop Function GetFileDlgEx(sIniDir,sFilter,sTitle) Set oDlg = CreateObject("WScript.Shell").Exec("mshta.exe ""about:<object id=d classid=clsid:3050f4e1-98b5-11cf-bb82-00aa00bdce0b></object><script>moveTo(0,-9999);eval(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(0).Read("&Len(sIniDir)+Len(sFilter)+Len(sTitle)+41&"));function window.onload(){var p=/[^\0]*/;new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(p.exec(d.object.openfiledlg(iniDir,null,filter,title)));close();}</script><hta:application showintaskbar=no />""") oDlg.StdIn.Write "var iniDir='" & sIniDir & "';var filter='" & sFilter & "';var title='" & sTitle & "';" GetFileDlgEx = oDlg.StdOut.ReadAll End Function


    --
    @+ Le Pivert
    1
  2. cs_Le Pivert Posted messages 8437 Status Contributor 730
     
    Hello,

    If it's to open a folder search dialog box, here is the code to paste into a text editor. Then save it. Show file extensions and rename this file to vbs instead of txt

    Const RETURNONLYFSDIRS = &H1 BIF_returnonlyfsdirs = &H0001 BIF_dontgobelowdomain = &H0002 BIF_editbox = &H0010 BIF_validate = &H0020 BIF_browseforcomputer = &H1000 Dim MyInputbox Dim Chemin Dim oFolder, oShell Set oShell = CreateObject("Shell.Application") Set oFolder = oShell.BrowseForFolder(&H0&, "Choose a directory", RETURNONLYFSDIRS, "c:\") If oFolder is Nothing Then MsgBox "Operator canceled",vbCritical Else Set oFolderItem = oFolder.Self Chemin=oFolderItem.path Chemin=InputBox("Copy to put the path in the clipboard", "Search folder path", Chemin) End If 


    --
    @+ Le Pivert
    0
  3. Papyx Posted messages 307 Registration date   Status Member Last intervention   11
     
    It's good for the folders, but it's the files that interest me.
    Thank you anyway.
    0
  4. Papyx Posted messages 307 Registration date   Status Member Last intervention   11
     
    Thank you, I should be able to manage with this code.
    0