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 :

Comment int�grer un Javascript dans un HTA �crit en Vbscript ?


Sujet :

VBScript

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Expert confirm�
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activit� : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par d�faut Comment int�grer un Javascript dans un HTA �crit en Vbscript ?

    J'ai ce code en HTA qui sert � convertir un texte en HTML.
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    <html>
    <head>
    <title>Exportation du Code Source avec coloration syntaxique en HTML © Hackoo © 2013</title>
    <HTA:APPLICATION
    APPLICATIONNAME="Exportation du Code Source avec coloration syntaxique en HTML © Hackoo © 2013"
    ID="Exportation du Code en HTML"
    ICON="Explorer.exe"
    BORDER="dialog"
    INNERBORDER="no"
    MAXIMIZEBUTTON="yes"
    SCROLL="no"
    VERSION="1.0"/>
    <style>
    Label
    {
    color : #123456;
    font-family : "Courrier New";
    }
    BODY {background-color:lightcyan;}
    input.button {  background-color : #EFEFEF;
    color : #000000; cursor:hand;
    font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; }
    }
    .alt2, .alt2Active
    {
    background: #E1E4F2;
    color: #000000;
    }    
    </style>
    </head>
    <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
    <script language="VBScript">
    Sub Window_OnLoad
        CenterWindow 450,200
    End Sub
    Sub CenterWindow(x,y)
        window.resizeTo x, y
        iLeft = window.screen.availWidth/2 - x/2
        itop = window.screen.availHeight/2 - y/2
        window.moveTo ileft, itop
    End Sub 
     
    Sub OnClickButtonCancel()
        Window.Close
    End Sub
     
    Function qq(strIn)
        qq = Chr(34) & strIn & Chr(34)
    End Function
     
    Function xPortCode(modName,sizeFont,InputFile,OutPutHTML)
        Dim i 
        Dim strBuff
        Dim reg 
        Dim KeyWords, KeyWordsList
        Dim Types, TypesList
        set fso = CreateObject("Scripting.FileSystemObject")
        Set reg = New regexp
        Set f = fso.OpenTextFile(OutPutHTML & ".html",2,True,-1)
        InputFile = file1.value
        If InputFile = "" Then
        MsgBox "ATTENTION ! "& vbcr & "Vous n'avez pas encore choisi un fichier !",48,"ATTENTION ! "& vbcr & "Vous n'avez pas encore choisi un fichier !"
        Exit Function
        End if
        Set f2 = Fso.OpenTextFile(InputFile,1)
        strBuff = f2.ReadAll '-- Lit la totalité du fichier
        NbLigneTotal = f2.Line 
        'MsgBox "Le Nombre Total de lignes est " & NbLigneTotal,64,"Nombre Total de lignes"
        Set Ws = CreateObject("Wscript.Shell")
    'écriture des en-têtes HTML et style
        f.Writeline "<HTML>"
        f.Writeline "<HEAD><TITLE>Export au format HTML du module : " & modName & "</TITLE>"
        f.Writeline "<meta http-equiv=""Content-Type"" content=""text/html; charset=ISO-8859-1"" />"
        f.Writeline "<style type='Text/css'>"
        f.Writeline "<!--"
        f.Writeline "BODY {background:lightcyan;"
        f.Writeline "margin-top:10; margin-left:10; margin-right:0;"
        f.Writeline "font-family: Lucida Console, Tahoma, Verdana, Arial, Helvetica, sans-serif;"
        f.Writeline "font-size: " & sizeFont & "px;" ' la variable argument sizeFont passe dans la définition du style
        f.Writeline "}"
        f.Writeline ".commentaire {"
        f.Writeline "color: #669933;"
        f.Writeline "}"
        f.Writeline ".chaine {"
        f.Writeline "color: Red"
        f.Writeline "}"
        f.Writeline ".key {"
        f.Writeline "color: #0033BB;"
        f.Writeline "}"
        f.Writeline ".type {"
        f.Writeline "font-weight: bold;"
        f.Writeline "color: #3366CC;"
        f.Writeline "}"
        f.Writeline "-->"
        f.Writeline "</style>"
        f.Writeline "</HEAD>"
        f.Writeline "<BODY>"
        f.Write "<pre class=""alt2"" dir=""ltr""><table cellspacing=""0"" cellpadding=""0""><tr><td valign=""top"" width=""33""><div style=""border: 1px dashed red; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: center; font-family: monospace"">"
        For X = 0 To NbLigneTotal - 1
            Y = X + 1
            f.Write "<font color=""Red"">" & Y & "</font>.<br />"
        Next
        f.Write "</div></td><td valign=""top""><pre style=""margin: 0"">"
     
    ' empêcher les ouvertures de tag HTML
        strBuff = Replace(strBuff, "<", "&lt;")
     
    ' les retours chariot
        reg.Pattern = "(\n)(<br />)"
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1<br />")
     
    ' 1- les mots-clés
        KeyWordsList = "AddressOf©Alias©And©As©ByRef©ByVal©Call©Case©Close©CBool©CByte©CCur©" & _
        "CDate©CDec©CDbl©CInt©CLng©CSng©CStr©CVar©Const©Compare©Database©Declare©Debug©Default©" & _
        "Dim©Do©Each©Else©ElseIf©End©Enum©Erase©Error©Explicit©Event©Exit©False©For©" & _
        "Friend©Function©Get©GoTo©Handles©If©Implements©Imports©In©Inherits©" & _
        "Interface©Is©Let©Lib©Like©Loop©Me©Mod©New©Next©Not©Nothing©" & _
        "On©Open©Option©Optional©Or©ParamArray©Preserve©Print©Private©Property©Protected©" & _
        "Public©RaiseEvent©ReadOnly©Redim©REM©Resume©Return©Select©Set©Shared©Static©" & _
        "Step©Stop©Sub©Then© To ©True©Type©TypeOf ©Until©UBound©When©Wend©While©With©WithEvents©WriteOnly©Xor"
     
        KeyWords = Split(KeyWordsList,"©")
        For i = 0 To UBound(KeyWords)
            reg.Pattern = "(\W|^)(" & KeyWords(i) & ")(\W|$)"
            reg.Multiline = False
            reg.Global = True
            reg.IgnoreCase = True
            strBuff = reg.Replace(strBuff, "$1<span class=key>$2</span>$3")
        Next 
     
    ' 2- les commentaires
    '  les REM
        reg.Pattern = "(\s)(rem .*)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1<span class=commentaire>$2</span>")    
     
    '  les apostrophes (')
        reg.Pattern = "(\n)(([^\x22\n]*\x22[^\x22\n]*\x22)*)([^\x22\n']*)('.*)."
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1$2$4<span class=commentaire>$5</span>")
     
    ' 3- les types
        TypesList = "Boolean©Byte©Date©Double©Integer©Long©Object©Short©Single©String©Unicode©Variant"
        Types = Split(TypesList, "©")
        For i = 0 To UBound(Types)
            reg.Pattern = "(\W|^)(" & Types(i) & ")(\W|$)"
            reg.Multiline = False
            reg.Global = True
            reg.IgnoreCase = True
            strBuff = reg.Replace(strBuff, "$1<span class=type>$2</span>$3")
        Next 
     
    ' 4- les chaines
        reg.Pattern = "(\x22[^\x22\n]*\x22)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "<span class=chaine>$1</span>")
     
    ' Highlight dans un Highlight
        reg.Pattern = "(<span class=\w{6,11}>)(.*)(<span class=\w{3,11}>)(.*)(</span>)(.*</span>)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        Do While reg.Test(strBuff)
            strBuff = reg.Replace(strBuff, "$1$2$4$6")
        Loop
     
    ' les espaces
        strBuff = Replace(strBuff, "  ", "  ")
    ' écriture de la chaîne dans le fichier
        f.Writeline strBuff
        f.Writeline "</td></tr></table></pre>"
        f.Writeline "</BODY>"
        IMG = "<center><img src='"&Chr(104)&Chr(116)&Chr(116)&Chr(112)&Chr(58)&Chr(47)&Chr(47)&Chr(110)&Chr(115)&Chr(109)&_
        Chr(48)&Chr(53)&Chr(46)&Chr(99)&Chr(97)&Chr(115)&Chr(105)&_
        Chr(109)&Chr(97)&Chr(103)&Chr(101)&Chr(115)&Chr(46)&Chr(99)&Chr(111)&Chr(109)&Chr(47)&Chr(105)&_
        Chr(109)&Chr(103)&Chr(47)&Chr(50)&Chr(48)&Chr(49)&Chr(49)&Chr(47)&Chr(48)&Chr(55)&Chr(47)&Chr(50)&_
        Chr(51)&Chr(47)&Chr(47)&Chr(49)&Chr(49)&Chr(48)&Chr(55)&_
        Chr(50)&Chr(51)&Chr(48)&Chr(55)&Chr(52)&Chr(49)&_
        Chr(52)&Chr(48)&Chr(49)&Chr(51)&Chr(49)&Chr(49)&Chr(48)&_
        Chr(52)&Chr(56)&Chr(53)&Chr(48)&Chr(54)&Chr(52)&Chr(49)&_
        Chr(57)&Chr(46)&Chr(103)&Chr(105)&Chr(102)&"' alt='"&Chr(104)&Chr(97)&_
        Chr(99)&Chr(107)&Chr(111)&Chr(111)&Chr(102)&Chr(114)&Chr(64)&_
        Chr(121)&Chr(97)&Chr(104)&Chr(111)&Chr(111)&Chr(46)&Chr(102)&Chr(114)&"'</img>"
        f.WriteLine IMG
        f.Writeline "</HTML>"             
        f.Close 
     
    'libération des objets mémoire
        Set reg = Nothing  
    'Ouverture du fichier HTML
        ws.Popup "La Conversion du ficher en HTML est terminé avec sucées !"&vbCr&_
        "Cliquer sur le Bouton OK pour ouvrir le fichier converti en HTML !","1","La Conversion du ficher en HTML est terminé avec sucées !",vbInformation
        ws.Run OutPutHTML & ".html",1,False
        Set Ws = Nothing
    End Function
    </script>
    <center>
    <label>Fichier à convertir en HTML </label><input type="file" name="file1" id="file1" /><br><br>
    <input type="button" style="width: 180px" name="OK" id="OK" value="Générer le fichier HTML" onclick="xPortCode 'Hackoo','14',file1.value,OutPutHTML">
    <input type="button" style="width: 100px" name="Cancel" id="Cancel" value="Sortir" onclick="OnClickButtonCancel"><br><br>
    <script language="Javascript" src="http://map.geoup.com/geoup?template=flag"></script>
    </body>
    </html>
    Puis j'ai cherch� � l�am�liorer un peu ce HTA en ajoutant une fonction pour s�lectionner tout le contenu du code source apr�s sa g�n�ration.
    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
    44
    45
    46
    function selectCode(a)
    {
        // Get ID of code block
        var e = a.parentNode.parentNode.getElementsByTagName('PRE')[1];
     
        // Not IE
        if (window.getSelection)
        {
            var s = window.getSelection();
            // Safari
            if (s.setBaseAndExtent)
            {
                s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
            }
            // Firefox and Opera
            else
            {
                // workaround for bug # 42885
                if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
                {
                    e.innerHTML = e.innerHTML + '&nbsp;';
                }
     
                var r = document.createRange();
                r.selectNodeContents(e);
                s.removeAllRanges();
                s.addRange(r);
            }
        }
        // Some older browsers
        else if (document.getSelection)
        {
            var s = document.getSelection();
            var r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
        }
        // IE
        else if (document.selection)
        {
            var r = document.body.createTextRange();
            r.moveToElementText(e);
            r.select();
        }
    }
    Donc mon probl�me est comment int�grer ce code �crit en Javascript dans ce HTA

  2. #2
    Expert confirm�
    Avatar de ProgElecT
    Homme Profil pro
    Retrait�
    Inscrit en
    D�cembre 2004
    Messages
    6 132
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 69
    Localisation : France, Haute Savoie (Rh�ne Alpes)

    Informations professionnelles :
    Activit� : Retrait�
    Secteur : Communication - M�dias

    Informations forums :
    Inscription : D�cembre 2004
    Messages : 6 132
    Par d�faut
    Salut hackoofr

    Code HTML : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    <SCRIPT language="javascript" type="text/javascript">
    <!--
            le code Javascript
    // -->
    </SCRIPT>
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont d�pann�s.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

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

    Informations professionnelles :
    Activit� : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par d�faut
    ProgElecT
    Je veux dire quelque chose comme ce code mais ce dernier ne marche pas
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    <html>
    <head>
    <title>Exportation du Code Source avec coloration syntaxique en HTML © Hackoo © 2013</title>
    <HTA:APPLICATION
    APPLICATIONNAME="Exportation du Code Source avec coloration syntaxique en HTML © Hackoo © 2013"
    ID="Exportation du Code en HTML"
    ICON="Explorer.exe"
    BORDER="dialog"
    INNERBORDER="no"
    MAXIMIZEBUTTON="yes"
    SCROLL="no"
    VERSION="1.0"/>
    <style>
    Label
    {
    color : #123456;
    font-family : "Courrier New";
    }
    BODY {background-color:lightcyan;}
    input.button {  background-color : #EFEFEF;
    color : #000000; cursor:hand;
    font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; }
    }
    .alt2, .alt2Active
    {
    background: #E1E4F2;
    color: #000000;
    }    
    </style>
    </head>
    <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
    <script language="VBScript">
    Sub Window_OnLoad
        CenterWindow 450,200
    End Sub
    Sub CenterWindow(x,y)
        window.resizeTo x, y
        iLeft = window.screen.availWidth/2 - x/2
        itop = window.screen.availHeight/2 - y/2
        window.moveTo ileft, itop
    End Sub 
     
    Sub OnClickButtonCancel()
        Window.Close
    End Sub
     
    Function qq(strIn)
        qq = Chr(34) & strIn & Chr(34)
    End Function
     
    Function xPortCode(modName,sizeFont,InputFile,OutPutHTML)
        Dim i 
        Dim strBuff
        Dim reg 
        Dim KeyWords, KeyWordsList
        Dim Types, TypesList
        set fso = CreateObject("Scripting.FileSystemObject")
        Set reg = New regexp
        Set f = fso.OpenTextFile(OutPutHTML & ".html",2,True,-1)
        InputFile = file1.value
        If InputFile = "" Then
        MsgBox "ATTENTION ! "& vbcr & "Vous n'avez pas encore choisi un fichier !",48,"ATTENTION ! "& vbcr & "Vous n'avez pas encore choisi un fichier !"
        Exit Function
        End if
        Set f2 = Fso.OpenTextFile(InputFile,1)
        strBuff = f2.ReadAll '-- Lit la totalité du fichier
        NbLigneTotal = f2.Line 
        'MsgBox "Le Nombre Total de lignes est " & NbLigneTotal,64,"Nombre Total de lignes"
        Set Ws = CreateObject("Wscript.Shell")
    'écriture des en-têtes HTML et style
        f.Writeline "<HTML>"
        f.Writeline "<HEAD><TITLE>Export au format HTML du module : " & modName & "</TITLE>"
        f.Writeline "<meta http-equiv=""Content-Type"" content=""text/html; charset=ISO-8859-1"" />"
        f.Writeline "<style type='Text/css'>"
        f.Writeline "<!--"
        f.Writeline "BODY {background:lightcyan;"
        f.Writeline "margin-top:10; margin-left:10; margin-right:0;"
        f.Writeline "font-family: Lucida Console, Tahoma, Verdana, Arial, Helvetica, sans-serif;"
        f.Writeline "font-size: " & sizeFont & "px;" ' la variable argument sizeFont passe dans la définition du style
        f.Writeline "}"
        f.Writeline ".commentaire {"
        f.Writeline "color: #669933;"
        f.Writeline "}"
        f.Writeline ".chaine {"
        f.Writeline "color: Red"
        f.Writeline "}"
        f.Writeline ".key {"
        f.Writeline "color: #0033BB;"
        f.Writeline "}"
        f.Writeline ".type {"
        f.Writeline "font-weight: bold;"
        f.Writeline "color: #3366CC;"
        f.Writeline "}"
        f.Writeline "-->"
        f.Writeline "</style>"
        f.WriteLine "<script type=""text/javascript"">"
        f.WriteLine "Function selectCode(a)"
        f.WriteLine "{"
        f.WriteLine "// Get ID of code block"
        f.WriteLine "var e = a.parentNode.parentNode.getElementsByTagName('PRE')[1];"
        f.WriteLine "// Not IE"
        f.WriteLine "if (window.getSelection)"
        f.WriteLine "{"
        f.WriteLine "    var s = window.getSelection();"
        f.WriteLine "    // Safari"
        f.WriteLine " if (s.setBaseAndExtent)"
        f.WriteLine "    {"
        f.WriteLine "        s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);"
        f.WriteLine "    }"
        f.WriteLine "    // Firefox and Opera"
        f.WriteLine "    else"
        f.WriteLine "    {"
        f.WriteLine "        // workaround for bug # 42885"
        f.WriteLine "        if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')"
        f.WriteLine "        {"
        f.WriteLine "            e.innerHTML = e.innerHTML + '&nbsp;';"
        f.WriteLine "        }"
        f.WriteLine "    var r = document.createRange();"
        f.WriteLine "        r.selectNodeContents(e);"
        f.WriteLine "        s.removeAllRanges();"
        f.WriteLine "        s.addRange(r);"
        f.WriteLine "    }"
        f.WriteLine " }"
        f.WriteLine " // Some older browsers"
        f.WriteLine " {"
        f.WriteLine "    var s = document.getSelection();"
        f.WriteLine "     var r = document.createRange();"
        f.WriteLine "    r.selectNodeContents(e);"
        f.WriteLine "    s.removeAllRanges();"
        f.WriteLine "    s.addRange(r);"
        f.WriteLine " }"
        f.WriteLine "// IE"
        f.WriteLine " else if (document.selection)"
        f.WriteLine "{"
        f.WriteLine "    var r = document.body.createTextRange();"
        f.WriteLine "     r.moveToElementText(e);"
        f.WriteLine "    r.select();"
        f.WriteLine "               }"
        f.WriteLine " }"
        f.Writeline "</script>"
        f.Writeline "</HEAD>"
        f.WriteLine "<button onclick=""Selectcode(this); return false;"">Sélectionner tout</button>"
        f.Writeline "<BODY>"
        f.Write "<pre class=""alt2"" dir=""ltr""><table cellspacing=""0"" cellpadding=""0""><tr><td valign=""top"" width=""33""><div style=""border: 1px dashed red; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: center; font-family: monospace"">"
        For X = 0 To NbLigneTotal - 1
            Y = X + 1
            f.Write "<font color=""Red"">" & Y & "</font>.<br />"
        Next
        f.Write "</div></td><td valign=""top""><pre style=""margin: 0"">"
     
    ' empêcher les ouvertures de tag HTML
        strBuff = Replace(strBuff, "<", "&lt;")
    ' les retours chariot
        reg.Pattern = "(\n)(<br />)"
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1<br />")
     
    ' 1- les mots-clés
        KeyWordsList = "AddressOf©Alias©And©As©ByRef©ByVal©Call©Case©Close©CBool©CByte©CCur©" & _
        "CDate©CDec©CDbl©CInt©CLng©CSng©CStr©CVar©Const©Compare©Database©Declare©Debug©Default©" & _
        "Dim©Do©Each©Else©ElseIf©End©Enum©Erase©Error©Explicit©Event©Exit©False©For©" & _
        "Friend©Function©Get©GoTo©Handles©If©Implements©Imports©In©Inherits©" & _
        "Interface©Is©Let©Lib©Like©Loop©Me©Mod©New©Next©Not©Nothing©" & _
        "On©Open©Option©Optional©Or©ParamArray©Preserve©Print©Private©Property©Protected©" & _
        "Public©RaiseEvent©ReadOnly©Redim©REM©Resume©Return©Select©Set©Shared©Static©" & _
        "Step©Stop©Sub©Then© To ©True©Type©TypeOf ©Until©UBound©When©Wend©While©With©WithEvents©WriteOnly©Xor"
     
        KeyWords = Split(KeyWordsList,"©")
        For i = 0 To UBound(KeyWords)
            reg.Pattern = "(\W|^)(" & KeyWords(i) & ")(\W|$)"
            reg.Multiline = False
            reg.Global = True
            reg.IgnoreCase = True
            strBuff = reg.Replace(strBuff, "$1<span class=key>$2</span>$3")
        Next 
     
    ' 2- les commentaires
    '  les REM
        reg.Pattern = "(\s)(rem .*)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1<span class=commentaire>$2</span>")    
     
    '  les apostrophes (')
        reg.Pattern = "(\n)(([^\x22\n]*\x22[^\x22\n]*\x22)*)([^\x22\n']*)('.*)."
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1$2$4<span class=commentaire>$5</span>")
     
    ' 3- les types
        TypesList = "Boolean©Byte©Date©Double©Integer©Long©Object©Short©Single©String©Unicode©Variant"
        Types = Split(TypesList, "©")
        For i = 0 To UBound(Types)
            reg.Pattern = "(\W|^)(" & Types(i) & ")(\W|$)"
            reg.Multiline = False
            reg.Global = True
            reg.IgnoreCase = True
            strBuff = reg.Replace(strBuff, "$1<span class=type>$2</span>$3")
        Next 
     
    ' 4- les chaines
        reg.Pattern = "(\x22[^\x22\n]*\x22)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "<span class=chaine>$1</span>")
     
    ' Highlight dans un Highlight
        reg.Pattern = "(<span class=\w{6,11}>)(.*)(<span class=\w{3,11}>)(.*)(</span>)(.*</span>)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        Do While reg.Test(strBuff)
            strBuff = reg.Replace(strBuff, "$1$2$4$6")
        Loop
     
    ' les espaces
        strBuff = Replace(strBuff, "  ", "  ")
    ' écriture de la chaîne dans le fichier
        f.Writeline strBuff
        f.Writeline "</td></tr></table></pre>"
        f.Writeline "</BODY>"
        IMG = "<center><img src='"&Chr(104)&Chr(116)&Chr(116)&Chr(112)&Chr(58)&Chr(47)&Chr(47)&Chr(110)&Chr(115)&Chr(109)&_
        Chr(48)&Chr(53)&Chr(46)&Chr(99)&Chr(97)&Chr(115)&Chr(105)&_
        Chr(109)&Chr(97)&Chr(103)&Chr(101)&Chr(115)&Chr(46)&Chr(99)&Chr(111)&Chr(109)&Chr(47)&Chr(105)&_
        Chr(109)&Chr(103)&Chr(47)&Chr(50)&Chr(48)&Chr(49)&Chr(49)&Chr(47)&Chr(48)&Chr(55)&Chr(47)&Chr(50)&_
        Chr(51)&Chr(47)&Chr(47)&Chr(49)&Chr(49)&Chr(48)&Chr(55)&_
        Chr(50)&Chr(51)&Chr(48)&Chr(55)&Chr(52)&Chr(49)&_
        Chr(52)&Chr(48)&Chr(49)&Chr(51)&Chr(49)&Chr(49)&Chr(48)&_
        Chr(52)&Chr(56)&Chr(53)&Chr(48)&Chr(54)&Chr(52)&Chr(49)&_
        Chr(57)&Chr(46)&Chr(103)&Chr(105)&Chr(102)&"' alt='"&Chr(104)&Chr(97)&_
        Chr(99)&Chr(107)&Chr(111)&Chr(111)&Chr(102)&Chr(114)&Chr(64)&_
        Chr(121)&Chr(97)&Chr(104)&Chr(111)&Chr(111)&Chr(46)&Chr(102)&Chr(114)&"'</img>"
        f.WriteLine IMG
        f.Writeline "</HTML>"             
        f.Close 
    'libération des objets mémoire
        Set reg = Nothing  
    'Ouverture du fichier HTML
        ws.Popup "La Conversion du ficher en HTML est terminé avec sucées !"&vbCr&_
        "Cliquer sur le Bouton OK pour ouvrir le fichier converti en HTML !","1","La Conversion du ficher en HTML est terminé avec sucées !",vbInformation
        ws.Run OutPutHTML & ".html",1,False
        Set Ws = Nothing
    End Function
    </script>
    <center>
    <label>Fichier à convertir en HTML </label><input type="file" name="file1" id="file1" /><br><br>
    <input type="button" style="width: 180px" name="OK" id="OK" value="Générer le fichier HTML" onclick="xPortCode 'Hackoo','14',file1.value,OutPutHTML">
    <input type="button" style="width: 100px" name="Cancel" id="Cancel" value="Sortir" onclick="OnClickButtonCancel"><br><br>
    <script language="Javascript" src="http://map.geoup.com/geoup?template=flag"></script>
    </body>
    </html>

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

    Informations professionnelles :
    Activit� : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par d�faut
    Ce code g�n�r� en HTML que je l'ai modifi� manuellement, fonnctionne 5/5 pour la s�lection. pour le tester enregistrer-le sous test.html
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    <HTML>
    <HEAD><TITLE>Export au format HTML du module : Hackoo</TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <style type='Text/css'>
    <!--
    BODY {background:lightcyan;
    margin-top:10; margin-left:10; margin-right:0;
    font-family: Lucida Console, Tahoma, Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
    }
    .commentaire {
    color: #669933;
    }
    .chaine {
    color: Red
    }
    .key {
    color: #0033BB;
    }
    .type {
    font-weight: bold;
    color: #3366CC;
    }
    -->
    </style>
    <script>
    function selectCode(a)
    {
        // Get ID of code block
        var e = a.parentNode.parentNode.getElementsByTagName('PRE')[1];
     
        // Not IE
        if (window.getSelection)
        {
            var s = window.getSelection();
            // Safari
            if (s.setBaseAndExtent)
            {
                s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
            }
            // Firefox and Opera
            else
            {
                // workaround for bug # 42885
                if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
                {
                    e.innerHTML = e.innerHTML + '&nbsp;';
                }
     
                var r = document.createRange();
                r.selectNodeContents(e);
                s.removeAllRanges();
                s.addRange(r);
            }
        }
        // Some older browsers
        else if (document.getSelection)
        {
            var s = document.getSelection();
            var r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
        }
        // IE
        else if (document.selection)
        {
            var r = document.body.createTextRange();
            r.moveToElementText(e);
            r.select();
        }
    }
    </script>
    </HEAD>
    <button onclick='selectCode(this); return false;'>Sélectionner tout</button>
    <BODY>
    <pre class="alt2" dir="ltr"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed red; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: center; font-family: monospace"><font color="Red">1</font>.<br /><font color="Red">2</font>.<br /><font color="Red">3</font>.<br /><font color="Red">4</font>.<br /><font color="Red">5</font>.<br /><font color="Red">6</font>.<br /><font color="Red">7</font>.<br /><font color="Red">8</font>.<br /></div></td><td valign="top"><pre style="margin: 0"><span class=key>Set</span> objWord = CreateObject(<span class=chaine>"Word.Application"</span>)
     objWord.Visible = <span class=key>False</span>
     <span class=key>Set</span> objDoc = objWord.Documents.<span class=key>Open</span>(<span class=chaine>"C:\Documents and Settings\Administrateur\Mes documents\Téléchargements\M.doc"</span>)
     objWord.Selection.TypeText <span class=chaine>"This is some text to test its working"</span>
     objDoc.Save
     objDoc.<span class=key>Close</span>
    <span class=key>Set</span> objDoc = <span class=key>Nothing</span>
    <span class=key>Set</span> objWord = <span class=key>Nothing</span>
    </td></tr></table></pre>
    </BODY>
    </HTML>
    Maintenant le probl�me r�side comment le g�n�rer dynamiquement par le HTA

  5. #5
    Expert confirm�
    Avatar de ProgElecT
    Homme Profil pro
    Retrait�
    Inscrit en
    D�cembre 2004
    Messages
    6 132
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 69
    Localisation : France, Haute Savoie (Rh�ne Alpes)

    Informations professionnelles :
    Activit� : Retrait�
    Secteur : Communication - M�dias

    Informations forums :
    Inscription : D�cembre 2004
    Messages : 6 132
    Par d�faut
    Je suis pas s�r de moi, mais ligne 142, je tenterai f.WriteLine "<button onclick=""javascript:Selectcode(this); return false;"">Sélectionner tout</button>"
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont d�pann�s.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

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

    Informations professionnelles :
    Activit� : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par d�faut
    Citation Envoy� par ProgElecT Voir le message
    Je suis pas s�r de moi, mais ligne 142, je tenterai f.WriteLine "<button onclick=""javascript:Selectcode(this); return false;"">S�lectionner tout</button>"
    j'ai essay� cette solution et �a ne marche pas

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

    Informations professionnelles :
    Activit� : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par d�faut
    Probl�me
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    <html>
    <head>
    <title>Exportation du Code Source avec coloration syntaxique en HTML © Hackoo © 2013</title>
    <HTA:APPLICATION
    APPLICATIONNAME="Exportation du Code Source avec coloration syntaxique en HTML © Hackoo © 2013"
    ID="Exportation du Code en HTML"
    ICON="Explorer.exe"
    BORDER="dialog"
    INNERBORDER="no"
    MAXIMIZEBUTTON="yes"
    SCROLL="no"
    VERSION="1.0"/>
    <style>
    Label
    {
    color : #123456;
    font-family : "Courrier New";
    }
    BODY {background-color:lightcyan;}
    input.button {  background-color : #EFEFEF;
    color : #000000; cursor:hand;
    font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; }
    }
    .alt2, .alt2Active
    {
    background: #E1E4F2;
    color: #000000;
    }    
    </style>
    </head>
    <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
    <script language="VBScript">
    Sub Window_OnLoad
        CenterWindow 450,200
    End Sub
    Sub CenterWindow(x,y)
        window.resizeTo x, y
        iLeft = window.screen.availWidth/2 - x/2
        itop = window.screen.availHeight/2 - y/2
        window.moveTo ileft, itop
    End Sub 
     
    Sub OnClickButtonCancel()
        Window.Close
    End Sub
     
    Function qq(strIn)
        qq = Chr(34) & strIn & Chr(34)
    End Function
     
    Function xPortCode(modName,sizeFont,InputFile,OutPutHTML)
        Dim i 
        Dim strBuff
        Dim reg 
        Dim KeyWords, KeyWordsList
        Dim Types, TypesList
        set fso = CreateObject("Scripting.FileSystemObject")
        Set reg = New regexp
        Set f = fso.OpenTextFile(OutPutHTML & ".html",2,True)
        InputFile = file1.value
        If InputFile = "" Then
            MsgBox "ATTENTION ! "& vbcr & "Vous n'avez pas encore choisi un fichier !",48,"ATTENTION ! "& vbcr & "Vous n'avez pas encore choisi un fichier !"
            Exit Function
        End if
        Set f2 = Fso.OpenTextFile(InputFile,1)
        strBuff = f2.ReadAll '-- Lit la totalité du fichier
        NbLigneTotal = f2.Line 
    'MsgBox "Le Nombre Total de lignes est " & NbLigneTotal,64,"Nombre Total de lignes"
        Set Ws = CreateObject("Wscript.Shell")
    'écriture des en-têtes HTML et style
        f.Writeline "<HTML>"
        f.Writeline "<HEAD><TITLE>Export au format HTML du module : " & modName & "</TITLE>"
        f.Writeline "<meta http-equiv=""Content-Type"" content=""text/html; charset=ISO-8859-1"" />"
        f.Writeline "<style type='Text/css'>"
        f.Writeline "<!--"
        f.Writeline "BODY {background:lightcyan;"
        f.Writeline "margin-top:10; margin-left:10; margin-right:0;"
        f.Writeline "font-family: Lucida Console, Tahoma, Verdana, Arial, Helvetica, sans-serif;"
        f.Writeline "font-size: " & sizeFont & "px;" ' la variable argument sizeFont passe dans la définition du style
        f.Writeline "}"
        f.Writeline ".commentaire {"
        f.Writeline "color: #669933;"
        f.Writeline "}"
        f.Writeline ".chaine {"
        f.Writeline "color: Red"
        f.Writeline "}"
        f.Writeline ".key {"
        f.Writeline "color: #0033BB;"
        f.Writeline "}"
        f.Writeline ".type {"
        f.Writeline "font-weight: bold;"
        f.Writeline "color: #3366CC;"
        f.Writeline "}"
        f.Writeline "-->"
        f.Writeline "</style>"
        f.WriteLine "<script>"
        f.WriteLine "function selectCode(a)"
        f.WriteLine "{"
        f.WriteLine "// Get ID of code block"
        f.WriteLine "var e = a.parentNode.parentNode.getElementsByTagName('PRE')[1];"
        f.WriteLine "// Not IE"
        f.WriteLine "if (window.getSelection)"
        f.WriteLine "{"
        f.WriteLine "    var s = window.getSelection();"
        f.WriteLine "    // Safari"
        f.WriteLine " if (s.setBaseAndExtent)"
        f.WriteLine "    {"
        f.WriteLine "        s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);"
        f.WriteLine "    }"
        f.WriteLine "    // Firefox and Opera"
        f.WriteLine "    else"
        f.WriteLine "    {"
        f.WriteLine "        // workaround for bug # 42885"
        f.WriteLine "        if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')"
        f.WriteLine "        {"
        f.WriteLine "            e.innerHTML = e.innerHTML + '&nbsp;';"
        f.WriteLine "        }"
        f.WriteLine "    var r = document.createRange();"
        f.WriteLine "        r.selectNodeContents(e);"
        f.WriteLine "        s.removeAllRanges();"
        f.WriteLine "        s.addRange(r);"
        f.WriteLine "    }"
        f.WriteLine " }"
        f.WriteLine " // Some older browsers"
        f.WriteLine " else if (document.getSelection)"
        f.WriteLine " {"
        f.WriteLine "    var s = document.getSelection();"
        f.WriteLine "     var r = document.createRange();"
        f.WriteLine "    r.selectNodeContents(e);"
        f.WriteLine "    s.removeAllRanges();"
        f.WriteLine "    s.addRange(r);"
        f.WriteLine " }"
        f.WriteLine "// IE"
        f.WriteLine " else if (document.selection)"
        f.WriteLine    "{"
        f.WriteLine "    var r = document.body.createTextRange();"
        f.WriteLine "     r.moveToElementText(e);"
        f.WriteLine "    r.select();"
        f.WriteLine     "}"
        f.WriteLine " }"
        f.Writeline "<HACKOOscript>"
        f.Writeline "</HEAD>"
        f.WriteLine "<button onclick='selectCode(this); return false;'>Sélectionner tout</button>"
        f.Writeline "<BODY>"
        f.Write "<pre class=""alt2"" dir=""ltr""><table cellspacing=""0"" cellpadding=""0""><tr><td valign=""top"" width=""33""><div style=""border: 1px dashed red; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: center; font-family: monospace"">"
        For X = 0 To NbLigneTotal - 1
            Y = X + 1
            f.Write "<font color=""Red"">" & Y & "</font>.<br />"
        Next
        f.Write "</div></td><td valign=""top""><pre style=""margin: 0"">"
     
    ' empêcher les ouvertures de tag HTML
        strBuff = Replace(strBuff, "<", "&lt;")
    ' les retours chariot
        reg.Pattern = "(\n)(<br />)"
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1<br />")
     
    ' 1- les mots-clés
        KeyWordsList = "AddressOf©Alias©And©As©ByRef©ByVal©Call©Case©Close©CBool©CByte©CCur©" & _
        "CDate©CDec©CDbl©CInt©CLng©CSng©CStr©CVar©Const©Compare©Database©Declare©Debug©Default©" & _
        "Dim©Do©Each©Else©ElseIf©End©Enum©Erase©Error©Explicit©Event©Exit©False©For©" & _
        "Friend©Function©Get©GoTo©Handles©If©Implements©Imports©In©Inherits©" & _
        "Interface©Is©Let©Lib©Like©Loop©Me©Mod©New©Next©Not©Nothing©" & _
        "On©Open©Option©Optional©Or©ParamArray©Preserve©Print©Private©Property©Protected©" & _
        "Public©RaiseEvent©ReadOnly©Redim©REM©Resume©Return©Select©Set©Shared©Static©" & _
        "Step©Stop©Sub©Then© To ©True©Type©TypeOf ©Until©UBound©When©Wend©While©With©WithEvents©WriteOnly©Xor"
     
        KeyWords = Split(KeyWordsList,"©")
        For i = 0 To UBound(KeyWords)
            reg.Pattern = "(\W|^)(" & KeyWords(i) & ")(\W|$)"
            reg.Multiline = False
            reg.Global = True
            reg.IgnoreCase = True
            strBuff = reg.Replace(strBuff, "$1<span class=key>$2</span>$3")
        Next 
     
    ' 2- les commentaires
    '  les REM
        reg.Pattern = "(\s)(rem .*)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1<span class=commentaire>$2</span>")    
     
    '  les apostrophes (')
        reg.Pattern = "(\n)(([^\x22\n]*\x22[^\x22\n]*\x22)*)([^\x22\n']*)('.*)."
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "$1$2$4<span class=commentaire>$5</span>")
     
    ' 3- les types
        TypesList = "Boolean©Byte©Date©Double©Integer©Long©Object©Short©Single©String©Unicode©Variant"
        Types = Split(TypesList, "©")
        For i = 0 To UBound(Types)
            reg.Pattern = "(\W|^)(" & Types(i) & ")(\W|$)"
            reg.Multiline = False
            reg.Global = True
            reg.IgnoreCase = True
            strBuff = reg.Replace(strBuff, "$1<span class=type>$2</span>$3")
        Next 
     
    ' 4- les chaines
        reg.Pattern = "(\x22[^\x22\n]*\x22)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        strBuff = reg.Replace(strBuff, "<span class=chaine>$1</span>")
     
    ' Highlight dans un Highlight
        reg.Pattern = "(<span class=\w{6,11}>)(.*)(<span class=\w{3,11}>)(.*)(</span>)(.*</span>)"
        reg.Multiline = False
        reg.Global = True
        reg.IgnoreCase = True
        Do While reg.Test(strBuff)
            strBuff = reg.Replace(strBuff, "$1$2$4$6")
        Loop
     
    ' les espaces
        strBuff = Replace(strBuff, "  ", "  ")
    ' écriture de la chaîne dans le fichier
        f.Writeline strBuff
        f.Writeline "</td></tr></table></pre>"
        f.Writeline "</BODY>"
        IMG = "<center><img src='"&Chr(104)&Chr(116)&Chr(116)&Chr(112)&Chr(58)&Chr(47)&Chr(47)&Chr(110)&Chr(115)&Chr(109)&_
        Chr(48)&Chr(53)&Chr(46)&Chr(99)&Chr(97)&Chr(115)&Chr(105)&_
        Chr(109)&Chr(97)&Chr(103)&Chr(101)&Chr(115)&Chr(46)&Chr(99)&Chr(111)&Chr(109)&Chr(47)&Chr(105)&_
        Chr(109)&Chr(103)&Chr(47)&Chr(50)&Chr(48)&Chr(49)&Chr(49)&Chr(47)&Chr(48)&Chr(55)&Chr(47)&Chr(50)&_
        Chr(51)&Chr(47)&Chr(47)&Chr(49)&Chr(49)&Chr(48)&Chr(55)&_
        Chr(50)&Chr(51)&Chr(48)&Chr(55)&Chr(52)&Chr(49)&_
        Chr(52)&Chr(48)&Chr(49)&Chr(51)&Chr(49)&Chr(49)&Chr(48)&_
        Chr(52)&Chr(56)&Chr(53)&Chr(48)&Chr(54)&Chr(52)&Chr(49)&_
        Chr(57)&Chr(46)&Chr(103)&Chr(105)&Chr(102)&"' alt='"&Chr(104)&Chr(97)&_
        Chr(99)&Chr(107)&Chr(111)&Chr(111)&Chr(102)&Chr(114)&Chr(64)&_
        Chr(121)&Chr(97)&Chr(104)&Chr(111)&Chr(111)&Chr(46)&Chr(102)&Chr(114)&"'</img>"
        f.WriteLine IMG
        f.Writeline "</HTML>"             
        f.Close 
        PatchScript
    'libération des objets mémoire
        Set reg = Nothing  
    'Ouverture du fichier HTML
        ws.Popup "La Conversion du ficher en HTML est terminé avec sucées !"&vbCr&_
        "Cliquer sur le Bouton OK pour ouvrir le fichier converti en HTML !","1","La Conversion du ficher en HTML est terminé avec sucées !",vbInformation
        ws.Run OutPutHTML & ".html",1,True
        Set Ws = Nothing
    End Function
     
    Sub PatchScript
        set fso = CreateObject("Scripting.FileSystemObject")
        Set freadHTML = fso.OpenTextFile(OutPutHTML & ".html",1)
        strBuffHTML = freadHTML.ReadAll
        strBuffHTML = Replace(strBuffHTML,"HACKOO","/")
        Set fwriteHTML = fso.OpenTextFile(OutPutHTML & ".html",2)
        fwriteHTML.Writeline strBuffHTML
    End Sub
    </script>
    <center>
    <label>Fichier à convertir en HTML </label><input type="file" name="file1" id="file1" /><br><br>
    <input type="button" style="width: 180px" name="OK" id="OK" value="Générer le fichier HTML" onclick="xPortCode 'Hackoo','14',file1.value,OutPutHTML">
    <input type="button" style="width: 100px" name="Cancel" id="Cancel" value="Sortir" onclick="OnClickButtonCancel"><br><br>
    <script language="Javascript" src="http://map.geoup.com/geoup?template=flag"></script>
    </body>
    </html>
    Et voila un aper�u d'un fichier de sortie en HTML par exemple le code lui-m�me Code2HTML.hta

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. Comment int�grer du JavaScript dans un site internet
    Par ManonL dans le forum G�n�ral JavaScript
    R�ponses: 5
    Dernier message: 04/01/2015, 19h45
  2. Comment int�grer du JSF dans du javascript
    Par dearraed dans le forum JSF
    R�ponses: 2
    Dernier message: 26/04/2013, 15h30
  3. R�ponses: 3
    Dernier message: 13/12/2005, 14h32
  4. Comment int�grer du perl dans une page html
    Par maniaco_jazz dans le forum Web
    R�ponses: 5
    Dernier message: 05/12/2005, 02h26
  5. R�ponses: 4
    Dernier message: 01/12/2005, 14h36

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