SCRIPT Existence fichier tableau html couleur

Etant novice, je cherche donc à me faire un script simple pour le completer au fur et à mesure…
Simplement : je veux si le fichier ou répertoire existe, mettre le fond la case en vert sinon en rouge et récupérer dans le tableau le nom + le chemin…

j’ai commencé mais là je suis bloquer

Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Fichier: Set Fichier = FSO.CreateTextFile(SListe & "Existence.html", 1, True)

strHTML=strHTML &"<center><h2><B><font color=red>Le Fichier existe t'il dans C:\ </font></B></h2></center>" &_
				"<table border='3' cellpadding='10' style='border-collapse: collapse; font size:11pt' bordercolor='#408080' width='auto' id='Table1'>" &_
				"<tr><td><strong>Nom du fichier :</strong></td>" &_
				"<td><strong>Chemin </strong></td>" &_
				"<td><strong>Existe ? ? ?</strong></td>" 
				
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists("C:\Outils") Then  'Fichier à TROUVER
    Set objFolder = objFSO.GetFile("C:\Outils") 'Fichier à TROUVER
	BGFLG_Existe = "Green"
Else
    BGFLG_Existe = "Red"
End If

Fichier.WriteLine strHTML 'Ecrire la structure du Tableau en HTML
Fichier.WriteLine "</table>" 'ici on ferme notre tableau par la balise </table>
'Fermeture du fichier contenant l'arborescence du répertoire à traiter
Fichier.Close

Edité le 19/05/2011 à 16:47

C’est un peu tordu : tu écris déjà la partie du tableau contenant la couleur avant de faire le test.

Teste ça :

Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Fichier: Set Fichier = FSO.CreateTextFile(SListe & "Existence.html", 1, True)


Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists("C:\Outils") Then 'Fichier à TROUVER
  Set objFolder = objFSO.GetFile("C:\Outils") 'Fichier à TROUVER
	BGFLG_Existe = "Green"
Else
  BGFLG_Existe = "Red"
End If

strHTML=strHTML &"<center><h2><B><font color=red>Le Fichier existe t'il dans C:\ </font></B></h2></center>" &_
				"<table border='3' cellpadding='10' style='border-collapse: collapse; font size:11pt' bordercolor='" & BGFLG_Existe & "' width='auto' id='Table1'>" &_
				"<tr><td><strong>Nom du fichier :</strong></td>" &_
				"<td><strong>Chemin </strong></td>" &_
				"<td><strong>Existe ? ? ?</strong></td>" 
				

Fichier.WriteLine strHTML 'Ecrire la structure du Tableau en HTML
Fichier.WriteLine "</table>" 'ici on ferme notre tableau par la balise </table>
'Fermeture du fichier contenant l'arborescence du répertoire à traiter
Fichier.Close

Ca marche oui & non (rien n’est simple)

C’est la couleur du tableau qui change et non la case mais je vais essayé de chercher :slight_smile:
[h2]
Trouvé ! Des Améliorations ???[/h2]

Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Fichier: Set Fichier = FSO.CreateTextFile(SListe & "Existence.html", 1, True)

Dim Chemin
Chemin = "C:\Documents and Settings\detourna\Bureau\Lister Droits\XCACLS.vbs" 'Emplacement fichier à CHANGER !!!

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(Chemin) Then 'Fichier à TROUVER
 Set objFolder = objFSO.GetFile(Chemin) 'Fichier à TROUVER
 
 strHTML=strHTML &"<img src='http://portail.euralis.intra/wps/themes/html/eurGroupeEuralis2011/img/bandeau.jpg' alt='Euralis'/>" &_
 "<center><h2><B><font color=red>Liste des Dossiers et Sous-Dossiers dans C:\ </font></B></h2></center>" &_
 "<table border='1' cellpadding='10' style='border-collapse: collapse; font size:11pt' bordercolor='#408080' width='100%' id='Table1'>" &_
 "<tr><td><strong>Chemin du Fichier :</strong></td>" &_
 "<TD><strong>Existe t'il ?</strong></td></tr>"&_
 "<td>" &Chemin & "</td>" &_
 "<TD BGCOLOR='Green'><center><strong> /!\ Il existe /!\ </center></strong></td></tr>"
 
Else
 strHTML=strHTML &"<img src='http://portail.euralis.intra/wps/themes/html/eurGroupeEuralis2011/img/bandeau.jpg' alt='Euralis'/>" &_
 "<center><h2><B><font color=red>Liste des Dossiers et Sous-Dossiers dans C:\ </font></B></h2></center>" &_
 "<table border='1' cellpadding='10' style='border-collapse: collapse; font size:11pt' bordercolor='#408080' width='100%' id='Table1'>" &_
 "<tr><td><strong>Chemin du Fichier :</strong></td>" &_
 "<TD><strong>Existe t'il ?</strong></td></tr>"&_
 "<td>" &Chemin & "</td>" &_
 "<TD BGCOLOR='Red'><center><strong> /!\ Il n'existe pas /!\ </center></strong></td></tr>"
 
End If

Fichier.WriteLine strHTML 'Ecrire la structure du Tableau en HTML
Fichier.WriteLine "</table>" 'ici on ferme notre tableau par la balise </table>
'Fermeture du fichier 
Fichier.Close

Edité le 20/05/2011 à 10:32

Ouais :slight_smile: le faire dans un vrai langage :stuck_out_tongue: