cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 201827 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