Bonjour,
J'essaie de scanner un répertoire et de récupérer le nom de tous les
fichiers dans un autre fichier excel.
Je fais ça en VBscript mais je sèche !!!
Bonjour,
J'essaie de scanner un répertoire et de récupérer le nom de tous les
fichiers dans un autre fichier excel.
Je fais ça en VBscript mais je sèche !!!
Bonjour,
J'essaie de scanner un répertoire et de récupérer le nom de tous les
fichiers dans un autre fichier excel.
Je fais ça en VBscript mais je sèche !!!
Dans le message news: ,
Mystique s'est ainsi exprimé:Bonjour,
J'essaie de scanner un répertoire et de récupérer le nom de tous les
fichiers dans un autre fichier excel.
Je fais ça en VBscript mais je sèche !!!
Voici un script de ma conception qui explore RÉCURSIVEMENT un dossier
(passé
en paramètre) et qui écrit cela dans EXCEL
Les nom de dossiers sont en gras.
Il y a respect de l'arborescence.
Tu peux améliorer (couleur, taille des caractères, ...)
Fichier "Folder2Excel.vbs"
------- couper ici -------
Set args = Wscript.Arguments
if args.count=0 then wscript.quit
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
folder=args(0)
if not fso.FolderExists(folder) then
Wscript.echo "Dossier inexistant"
wscript.quit
end if
Set oXL = WScript.CreateObject("EXCEL.application")
oXL.Visible = True
oXL.Workbooks.Add
NumL=2
Numc=1
Explore folder,1
oXL.Selection.Columns.AutoFit
oXL.Cells.Select
oXL.Selection.Columns.AutoFit
Wscript.quit
'--------------------------------------------------------------------
Sub Explore(dossier,niveau)
set f=fso.GetFolder(dossier)
set collFic=f.Files
set collDir=f.SubFolders
Cellule NumL,Niveau,f.Name,true,false,0
For each SubDir in CollDir
Explore dossier & "" & SubDir.Name,niveau+1
Next
For each Fic in collfic
Cellule NumL,Niveau+1,Fic.Name,false,false,0
NumL=NumL+1
Next
End Sub
'-----------------------------------------------
Function GetPath()
Dim path
path = WScript.ScriptFullName
GetPath = Left(path, InStrRev(path, ""))
End Function
'********* sous-programmes EXCEL *********
Sub Cellule(NumL,NumC,chaine,casse,italic,size)
oXL.Cells(NumL,NumC).Value = Chaine
If casse or size<>0 Then
CoordsÎllName(NumL,NumC)
oXL.Range(Coords & ":" & Coords).Select
If casse Then oXL.Selection.Font.Bold = True
If italic Then oXL.Selection.Font.Italic = True
If size<>0 Then oXL.Selection.Font.Size = size
End If
End Sub
'-----------------------------------------------
Function ColName(NumC)
If NumC<& Then
ColName=chr(64+NumC)
Else
n1=int(NumC/26)
n2=NumC-n1*26
ColName=chr(64+n1) & chr(64+n2)
End If
End Function
'-----------------------------------------------
Function CellName(NumL,NumC)
CellName=ColName(NumC) & NumL
End Function
------- couper ici -------
--
May the Force be with You!
La Connaissance s'accroît quand on la partage
----------------------------------------------------------
Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org
*
Dans le message news:427E7CB1-D41C-44C9-9322-58148E821EA0@microsoft.com ,
Mystique <Mystique@discussions.microsoft.com> s'est ainsi exprimé:
Bonjour,
J'essaie de scanner un répertoire et de récupérer le nom de tous les
fichiers dans un autre fichier excel.
Je fais ça en VBscript mais je sèche !!!
Voici un script de ma conception qui explore RÉCURSIVEMENT un dossier
(passé
en paramètre) et qui écrit cela dans EXCEL
Les nom de dossiers sont en gras.
Il y a respect de l'arborescence.
Tu peux améliorer (couleur, taille des caractères, ...)
Fichier "Folder2Excel.vbs"
------- couper ici -------
Set args = Wscript.Arguments
if args.count=0 then wscript.quit
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
folder=args(0)
if not fso.FolderExists(folder) then
Wscript.echo "Dossier inexistant"
wscript.quit
end if
Set oXL = WScript.CreateObject("EXCEL.application")
oXL.Visible = True
oXL.Workbooks.Add
NumL=2
Numc=1
Explore folder,1
oXL.Selection.Columns.AutoFit
oXL.Cells.Select
oXL.Selection.Columns.AutoFit
Wscript.quit
'--------------------------------------------------------------------
Sub Explore(dossier,niveau)
set f=fso.GetFolder(dossier)
set collFic=f.Files
set collDir=f.SubFolders
Cellule NumL,Niveau,f.Name,true,false,0
For each SubDir in CollDir
Explore dossier & "" & SubDir.Name,niveau+1
Next
For each Fic in collfic
Cellule NumL,Niveau+1,Fic.Name,false,false,0
NumL=NumL+1
Next
End Sub
'-----------------------------------------------
Function GetPath()
Dim path
path = WScript.ScriptFullName
GetPath = Left(path, InStrRev(path, ""))
End Function
'********* sous-programmes EXCEL *********
Sub Cellule(NumL,NumC,chaine,casse,italic,size)
oXL.Cells(NumL,NumC).Value = Chaine
If casse or size<>0 Then
CoordsÎllName(NumL,NumC)
oXL.Range(Coords & ":" & Coords).Select
If casse Then oXL.Selection.Font.Bold = True
If italic Then oXL.Selection.Font.Italic = True
If size<>0 Then oXL.Selection.Font.Size = size
End If
End Sub
'-----------------------------------------------
Function ColName(NumC)
If NumC<& Then
ColName=chr(64+NumC)
Else
n1=int(NumC/26)
n2=NumC-n1*26
ColName=chr(64+n1) & chr(64+n2)
End If
End Function
'-----------------------------------------------
Function CellName(NumL,NumC)
CellName=ColName(NumC) & NumL
End Function
------- couper ici -------
--
May the Force be with You!
La Connaissance s'accroît quand on la partage
----------------------------------------------------------
Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org
Jean-Claude.Bellamy@wanadoo.fr * JC.Bellamy@free.fr
Dans le message news: ,
Mystique s'est ainsi exprimé:Bonjour,
J'essaie de scanner un répertoire et de récupérer le nom de tous les
fichiers dans un autre fichier excel.
Je fais ça en VBscript mais je sèche !!!
Voici un script de ma conception qui explore RÉCURSIVEMENT un dossier
(passé
en paramètre) et qui écrit cela dans EXCEL
Les nom de dossiers sont en gras.
Il y a respect de l'arborescence.
Tu peux améliorer (couleur, taille des caractères, ...)
Fichier "Folder2Excel.vbs"
------- couper ici -------
Set args = Wscript.Arguments
if args.count=0 then wscript.quit
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
folder=args(0)
if not fso.FolderExists(folder) then
Wscript.echo "Dossier inexistant"
wscript.quit
end if
Set oXL = WScript.CreateObject("EXCEL.application")
oXL.Visible = True
oXL.Workbooks.Add
NumL=2
Numc=1
Explore folder,1
oXL.Selection.Columns.AutoFit
oXL.Cells.Select
oXL.Selection.Columns.AutoFit
Wscript.quit
'--------------------------------------------------------------------
Sub Explore(dossier,niveau)
set f=fso.GetFolder(dossier)
set collFic=f.Files
set collDir=f.SubFolders
Cellule NumL,Niveau,f.Name,true,false,0
For each SubDir in CollDir
Explore dossier & "" & SubDir.Name,niveau+1
Next
For each Fic in collfic
Cellule NumL,Niveau+1,Fic.Name,false,false,0
NumL=NumL+1
Next
End Sub
'-----------------------------------------------
Function GetPath()
Dim path
path = WScript.ScriptFullName
GetPath = Left(path, InStrRev(path, ""))
End Function
'********* sous-programmes EXCEL *********
Sub Cellule(NumL,NumC,chaine,casse,italic,size)
oXL.Cells(NumL,NumC).Value = Chaine
If casse or size<>0 Then
CoordsÎllName(NumL,NumC)
oXL.Range(Coords & ":" & Coords).Select
If casse Then oXL.Selection.Font.Bold = True
If italic Then oXL.Selection.Font.Italic = True
If size<>0 Then oXL.Selection.Font.Size = size
End If
End Sub
'-----------------------------------------------
Function ColName(NumC)
If NumC<& Then
ColName=chr(64+NumC)
Else
n1=int(NumC/26)
n2=NumC-n1*26
ColName=chr(64+n1) & chr(64+n2)
End If
End Function
'-----------------------------------------------
Function CellName(NumL,NumC)
CellName=ColName(NumC) & NumL
End Function
------- couper ici -------
--
May the Force be with You!
La Connaissance s'accroît quand on la partage
----------------------------------------------------------
Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org
*
Bonjour,
Merci Jean-Claud : il marche très très bien !!!
Yapadkoi ! ;-)
Bonjour,
Merci Jean-Claud : il marche très très bien !!!
Yapadkoi ! ;-)
Bonjour,
Merci Jean-Claud : il marche très très bien !!!
Yapadkoi ! ;-)