IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Existence fichier tableau html couleur


Sujet :

VBScript

  1. #1
    Membre confirmé

    Homme Profil pro
    Informaticien Généraliste
    Inscrit en
    Mai 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Informaticien Généraliste
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 78
    Par défaut 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

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    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

  2. #2
    Membre confirmé

    Homme Profil pro
    Informaticien Généraliste
    Inscrit en
    Mai 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Informaticien Généraliste
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 78
    Par défaut
    j'avance mais c'est le tableau qui change et non le fond de la case ? une idée
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    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:\Documents and Settings\detourna\Bureau\Lister Droits\XCACLS.vbs") Then 'Fichier à TROUVER
     Set objFolder = objFSO.GetFile("C:\Documents and Settings\detourna\Bureau\Lister Droits\XCACLS.vbs") 'Fichier à TROUVER
    BGFLG_Existe = "Yellow"
    Else
     BGFLG_Existe = "Red"
    End If
     
    strHTML=strHTML &"<center><h2><B><font color=Grey>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

  3. #3
    Membre Expert
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Par défaut
    Bonjour,

    Tu utilises ta variable BGFLG_Existe dans la balise <table>. Si tu veux modifier une cellule, il faut mettre cette variable dans la balise <td>.

  4. #4
    Membre confirmé

    Homme Profil pro
    Informaticien Généraliste
    Inscrit en
    Mai 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Informaticien Généraliste
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 78
    Par défaut
    J'ai trouvé !

    Mais n'avez vous pas une solution plus simple, ou facile ou amélioration de ce code ?

    MERCI

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    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


    J'ai fais également une inputbox mais je voudrais qu'a la fin du prog il m'ouvre le fichier html IDEE ?

  5. #5
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 843
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 843
    Par défaut
    Citation Envoyé par Lexounet Voir le message
    J'ai fais également une inputbox mais je voudrais qu'a la fin du prog il m'ouvre le fichier html IDEE ?
    IDEE c'est quoi Tu veux Dire "IE" "Internet Explorer" si c'est le cas alors essaye ce Code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    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
     
    Call Explorer("Existence.html")
     
    Function Explorer(File)
         Set fso = CreateObject("Scripting.FileSystemObject")
         Set ws=CreateObject("wscript.shell")
    	 GetAbsolutePath = fso.GetAbsolutePathName(file)
    	 ws.run "iexplore " & GetAbsolutePath
    end Function

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Tableau Html a convertir en fichier Excel
    Par guispider dans le forum Langage
    Réponses: 3
    Dernier message: 19/02/2009, 11h39
  2. [AJAX] tableau HTML joint sous forme de fichiers
    Par fthem dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 03/09/2008, 09h01
  3. Alterner la couleur des ligne dans un tableau html
    Par arnaudperfect dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 28/01/2008, 14h57
  4. [XSLT][HTML] couleur de font des lignes d un tableau
    Par Mil17 dans le forum XSL/XSLT/XPATH
    Réponses: 9
    Dernier message: 03/08/2007, 10h37
  5. [CSV] Conversion d'un tableau html en un fichier csv
    Par MnzNezo dans le forum Langage
    Réponses: 5
    Dernier message: 11/07/2007, 15h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo