Equivalent en vbs de comondialog

Résolu
gphoebus Messages postés 13 Date d'inscription mercredi 9 avril 2003 Statut Membre Dernière intervention 16 janvier 2008 - 1 oct. 2006 à 19:53
gphoebus Messages postés 13 Date d'inscription mercredi 9 avril 2003 Statut Membre Dernière intervention 16 janvier 2008 - 2 oct. 2006 à 00:17
Bonsoir à tous.


Y a t'il moyen de faire la même chose en VBS que le composant comon dialog ou mêmeun dirlistbox
Cordialement à tous,

Phoebus

2 réponses

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
1 oct. 2006 à 20:39
 Bonsoir à tous....

exemple sans CommonDialog:
BIF_returnonlyfsdirs   = &H0001
BIF_dontgobelowdomain  = &H0002
BIF_editbox            = &H0010
BIF_validate           = &H0020
BIF_browseforcomputer  = &H1000


Dim shell, item
Set shell = WScript.CreateObject("Shell.Application")
flag=BIF_returnonlyfsdirs
titre="Test de sélection de dossier"
Set Item = shell.BrowseForFolder(0,titre,flag, dirinit)
'If isvalue(Item) Then
 Result=Item.Title
 MsgBox Result
' Test si on a sélectionné la racine d'une partition


 If InStr(1,Result,":")=0 Then
  'MsgBox  Item.ParentFolder.ParseName(Item.Titre).Path
  End If
 wscript.echo "On a choisi : " & Result
'else
 'wscript.echo "On a appuyé sur Annuler"
 'End If
Wscript.quit

exemples simples avec CommonDialog:
Dim oUA, WshShell, chemin, fichier
Set oUA = CreateObject("UserAccounts.CommonDialog")
Set WshShell=CreateObject("WScript.Shell")
chemin = oUA.ShowOpen
fichier = oUA.FileName
MsgBox fichier
'WshShell.Run(fichier)
Set oUA = Nothing
Set WshShell = Nothing
 ou
'Ce script permet d'ouvrir une fenêtre Explorer
'et affiche le nom du fichier selectionné par l'utilisateur
Dim WshShell, objDlg
Set WshShell = wscript.CreateObject("wscript.Shell")
Set objDlg = wscript.CreateObject("MSComDlg.CommonDialog")
'choix de l'affichage
'objDlg.Filter = "All Files (*.*)|*.*|coucou Files (*.txt)|*.txt|jean-marc"
'Positionnement de la fenêtre
objDlg.FilterIndex = 2
objDlg.MaxFileSize = 260
objDlg.CancelError = true
objDlg.ShowOpen


MsgBox "Répertoire et Fichier: " & objDlg.FileName &vbCrLf&_
       "Fichier: " & Mid(objDlg.FileName, InStrRev(objDlg.FileName, "") + 1)


Set WshShell = Nothing
Set objDlg = Nothing
Set fso = Nothing

jean-marc
3
gphoebus Messages postés 13 Date d'inscription mercredi 9 avril 2003 Statut Membre Dernière intervention 16 janvier 2008
2 oct. 2006 à 00:17
Exactement ce que je cherchais.


Merci

Phoebus
0
Rejoignez-nous