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

VBA Discussion :

Webbrowser n'affiche pas la page


Sujet :

VBA

  1. #21
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    Tu as tout à fait raison. C est pourquoi j attends ta solution !

  2. #22
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    re
    BON!! allez un premier jet je n'ai pas mis tout les boutons mais iles parfaitement fonctionel

    alors dans un module standard tu va mettre ceci:

    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
    Option Explicit
    Const bold = "comd:false:null:bold:113:Texte en gras"
    Const italic = "comd:false:null:italic:114:Mettre le texte de la selection en italic"
    Const underline = "comd:false:null:underline:115:Souligner le texte"
    Const fontName = "listeF:::fontName:1063:Afficher la liste des font name"
    Const fontSize = "listeFZ:::fontSize:1061:Afficher la liste des font size"
    Const foreColor = "palette:::foreColor:1858:Afficher la palette des font color"    'ou 401
    Const backColor = "paletteback:::backColor:1031:Texte avec le Fond en couleur"
    Const indent = "comd:false:null:indent:3161:indenter le texte"
    Const outdent = "comd:false:null:outdent:3162:outdenter le texte"
    Const subscript = "comd:false:null:subscript:333:Mettre en souexposant le texte sélectionné"
    Const superscript = "comd:false:null:superscript:333:Mettre le texte sélectionné en exposant"
    Const copy = "comd:false:null:copy:19:Copier la selection "
    Const cut = "comd:false:null:cut:21:Couper la selection"
    Const paste = "comd:false:true:paste:22:coller"
    Const createLink = "comd:false:null:createLink:1015:Mettre un lien sur la selection"
    Const unlink = "comd:false:null:unlink:1576:Suprimer le lien "
    Const insertHorizontalRule = "comd:false:null:insertHorizontalRule:333:Tirer un trait"
    Const insertOrderedList = "comd:false:null:insertOrderedList:333:insérer ou transformer la selection en liste ordonnée"
    Const insertUnorderedList = "comd:false:null:insertUnorderedList:333:insérer ou transformer la selection en liste non ordonnée"
    Const justifyCenter = "comd:false:null:justifyCenter:122:Centrer le texte"
    Const justifyLeft = "comd:false:null:justifyLeft:120:Aligner le texte a gauche "
    Const justifyRight = "comd:false:null:justifyRight:121:Aligner le texte a droite"
    Const redo = "comd:false:null:redo:333:refaire"
    Const removeFormat = "comd:false:null:removeFormat:108:suprimer le formatage du texte"
    Const strikeThrough = "comd:false:null:strikeThrough:333:Barrer le texte sélectionné"
    Const undo = "comd:false:null:undo:Annuler la dernier operation"
    Const insertimg = "insertimg:false:null:insertimage:682:inserer une image "
    Const html = "afficherhtml:::afficherhtml:109:Afficher le code HTML"
    Sub test()
        Dim CSS As String, Code As String, Doctype As String, Meta As String, arrbout, arrface, x, fichier As String, fN, Bouton, But, i, prop, graf
        Dim script, pann, Fondbout, Bout, r, ppp, pal, c, H, couleur, Pa, Fname, opt, Fnn, Fz, Fsize
        Bouton = Array(bold, italic, foreColor, underline, fontName, fontSize, justifyLeft, justifyCenter, justifyRight, indent, outdent, removeFormat, copy, cut, paste, createLink, unlink)
        fN = Array("F-name", "arial", "calibri", "algerian", "arialblack", "aharoni", "baskerville", "comic sans ms", "forte", "georgia", "script")
        'on sauve les image des boutons dans des fichier image solides
        If Dir(Environ("userprofile") & "\Desktop\imageBouton\") = "" Then MkDir Environ("userprofile") & "\desktop\imageBouton"
        Set But = CommandBars(1).Controls.Add(Type:=msoControlButton)
        For i = 0 To UBound(Bouton)
            prop = Split(Bouton(i), ":")
            With But: .FaceId = prop(4): .CopyFace
                With ActiveSheet: Set graf = .ChartObjects.Add(0, 0, 10, 10)
                    graf.Chart.paste
                    graf.Chart.Export Filename:=Environ("userprofile") & "\Desktop\imageBouton\" & prop(3) & ".png"
                    graf.Delete
                End With
            End With
        Next
     
     
        'un peu de style css necessaire a la presentation
        CSS = "<style>||HTML{|  width:100%;|  height:100%;|}|"
        CSS = CSS & "*{|  margin: 0;|  padding: 0;|}|"
        CSS = CSS & "|html{|  width: 100%;|  height: 100%;|  min-height: 100%;|}|"
        CSS = CSS & "|body{|  display: flex; display: -webkit-flex;|  flex-direction:column;|  width: 99%;|  margin: 0.5%;|  height: 99%;|  margin-top:-2px;|  border: 1px solid green;|}|"
        CSS = CSS & "|#panne {|  background: linear-gradient(to right, rgba(247,251,252,1) 0%,rgba(217,237,242,1) 40%,rgba(173,217,228,1) 100%);|  white-space:wrap;|  display:inline -block;|}|"
        CSS = CSS & "|.panlitle{|flex: 0 0 30pt; -webkit-flex: 0 0 40px;|  height: 40px;|}|"
        CSS = CSS & "|.panbig{|flex: 0 0 50pt; -webkit-flex: 0 0 70px;|  height: 70px;|}|"
        CSS = CSS & "|#editeur{| flex: 1 1 auto; -webkit-flex: 1 0 auto;| overflow:auto;| font-size:18px;| border:1px solid gray;|  overflow:auto;|}|"
        CSS = CSS & "|.fondbouton{| display:block;|  background-color:#F2F2F2;|  width:25px;| height:25px;| margin-left:5px;| margin-top:3px;| border:1px solid black;| float:left;| border-radius:7px;|  overflow:hidden;|}|"
        CSS = CSS & "|.bouton{| width:104%;| height:102%;|  margin-left:2px;|}|"
        CSS = CSS & "|.fondbouton:hover {|border:1px solid red;|}|"
        CSS = CSS & "|#palette{| background-color:gray;|  font-size=1px;| display:block;|  width:190px;|  height:170px;position:absolute;|  top:30px;|  left:5px;|  border:1px solid black;|}|"
        CSS = CSS & "|.Bcolor{|  font_size:0px;|  fload:left;|  width:15px;|  height:15px;|  margin-top:0px;|  margin-left:0px;|  border;1px solid black;|}|"
        CSS = CSS & "|#fname{|  position:absolute;|  top:30px;|  left:120px;|}|"
        CSS = CSS & "|#fsize{|  position:absolute;|  top:30px;|  left:145px;|  width:80px;|}|"
        CSS = CSS & "|p{| margin:0|}|"
        CSS = CSS & "|</style>|"
        'la fonction execCommand dans la balise script en javascript
        script = "|<script type=""text/javascript"">|||"
        script = script & "function execCom(fonction, argmt1,argmt2) {|"
        script = script & "   if(argmt1===undefined){argmt1=false;}|"
        script = script & "   if(argmt2===undefined){argmt2=null;}|"
        script = script & "   document.execCommand(fonction,argmt1,argmt2);|"
        script = script & "   var pal=document.getElementById('palette');|   pal.style.visibility=""hidden"";|"
        script = script & "   var L=document.getElementById('fname');|   L.style.visibility=""hidden"";|"
        script = script & "   var fz=document.getElementById('fsize');|   fz.style.visibility=""hidden"";|}|"
        'd'autre fonctions javascript basiques
        script = script & "function palette(mode){|   var pal=document.getElementById(""palette"");|   pal.style.visibility=""visible"";|}|"
        script = script & "function listeF(){|   var L=document.getElementById(""fname"");|   L.style.visibility=""visible"";|}|"
        script = script & "function listeFZ(){|   var L=document.getElementById(""fsize"");|   L.style.visibility=""visible"";|}|"
        script = script & "function resizepann(){| var w = window.outerWidth;|  var pan=document.getElementById(""panne"");|  if(w<650){pan.className=""panbig"";}|  if(w>650){pan.className=""panlitle"";}|}|"
        'suite fonction avenir
        script = script & "|</script>|"
        With CreateObject("htmlfile")
            '---------------------------------------------------------------------------------------------------------
            'creation du ruban et ses boutons
            Set pann = .createelement("DIV"): pann.ID = "panne"
            For i = 0 To UBound(Bouton)
                prop = Split(Bouton(i), ":")
                Set Fondbout = .createelement("DIV")
                Fondbout.classname = "fondbouton"
                Set Bout = .createelement("img")
                With Bout: .ID = prop(3): .Title = prop(5): .classname = "bouton"
                    r = .setAttribute("src", "file://" & Environ("userprofile") & "\Desktop\imageBouton\" & prop(3) & ".png")
                    If prop(0) = "comd" Then .onclick = "execCom('" & prop(3) & "','" & prop(1) & "','" & prop(2) & "')"
                    If prop(0) = "palette" Then .onclick = "palette('ForeColor')"
                    If prop(0) = "listeF" Then .onclick = "listeF('i')"
                    If prop(0) = "listeFZ" Then .onclick = "listeFZ('i')"
                End With
                Fondbout.appendchild (Bout)
                pann.appendchild (Fondbout)
                pann.classname = "panlitle"
                'MsgBox .Document.getelementbyid(arrbout(i)).outerhtml
            Next
            'recuperation de code outerhtml du ruban(avec ces boutons)
            ppp = pann.outerhtml
            '---------------------------------------------------------------------------------------------------------
            'creation de la palette couleur et ses boutons avec les 56 couleurs d'Excel au format HTML
            Set pal = .createelement("DIV"): pal.ID = "palette": pal.Style.visibility = "hidden"
            For c = 1 To 56
                H = Right("000000" & Hex(ThisWorkbook.Colors(c)), 6)
                couleur = Right(H, 2) & Mid(H, 3, 2) & Left(H, 2)
                Set Bout = .createelement("BUTTON")
                With Bout
                    .Style.backgroundcolor = "#" & couleur
                    .classname = "Bcolor"
                    .onclick = "execCom('ForeColor','false','" & "#" & couleur & "')"
                    pal.appendchild (Bout)
                End With
            Next
            Pa = Replace(pal.outerhtml, "><", ">" & vbCrLf & "<")
            '---------------------------------------------------------------------------------------------------------
            'creation de la liste des font name
            Set Fname = .createelement("SELECT"): Fname.ID = "fname": Fname.Style.visibility = "hidden": Fname.Size = UBound(fN) + 1
            Fname.onchange = "execCom('fontName','false', this.value )"
            For i = 0 To UBound(fN)
                Set opt = .createelement("OPTION"): opt.Value = fN(i): opt.innerhtml = fN(i)
                Fname.appendchild (opt)
            Next
            Fnn = Replace(Fname.outerhtml, "><", ">" & vbCrLf & "<")
            '---------------------------------------------------------------------------------------------------------
            'creation de la liste des font size
            Set Fsize = .createelement("SELECT"): Fsize.ID = "fsize": Fsize.Style.visibility = "hidden": Fsize.Size = 7
            Fsize.onchange = "execCom('fontSize','false', this.value )"
            For i = 1 To 7
                Set opt = .createelement("OPTION"): opt.Value = i: opt.innerhtml = i
                Fsize.appendchild (opt)
            Next
            Fz = Replace(Fsize.outerhtml, "><", ">" & vbCrLf & "<")
        End With
        '---------------------------------------------------------------------------------------------------------
        'rassemblement du code pour ecriture dans un fichier
        Doctype = "<!DOCTYPE html >|"
        Meta = "<html lang=""fr"">|<meta charset=""utf-8"">|"
        Meta = Meta & "<meta http-equiv=""X-UA-Compatible"" content=""IE=11"">|"
        Code = Doctype & "|<html>|<head>|" & Meta & "|" & CSS & "|" & script & "|</head>|<body onresize=""resizepann()"">|" & ppp & "|</div>|<div id=""editeur"" contenteditable=true><p></p></div>|" & Pa & "|" & Fnn & "|" & Fz & "|</body>|</html>"
        Code = Replace(Code, "|", vbCrLf)
        'Debug.Print Code
        fichier = Environ("userprofile") & "\Desktop\wig.html"
        x = FreeFile
        Open fichier For Output As #x
        Print #x, Code
        Close #x
        CommandBars(1).Reset
    End Sub
    ensuite dans un userform tu va mettre 1 !! WebBrowser et c'est tout

    dans le code du userform tu mettre ceci:
    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
    Option Explicit
    Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function fwa Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Sub UserForm_Activate()
        Dim handle
        test
        handle = fwa(vbNullString, Me.Caption)
        SetWindowLongA handle, -16, &H94CF0080
        With WebBrowser1
            .Silent = True
            .Navigate Environ("userprofile") & "\Desktop\wig.html"
          End With
    End Sub
    Private Sub UserForm_Resize()
        With WebBrowser1: .width = Me.InsideWidth - 5: .height = Me.InsideHeight - 5: End With
    End Sub
    voila tu a ton wysiwyg perso tout est créé dynamiquement
    rien ne t'empeche de mettre tout ca directement dans le userform hein

    appercu
    Nom : Capture.JPG
Affichages : 203
Taille : 112,4 Ko

    il est parfaitement resizable comme ci dessous
    Nom : demo3.gif
Affichages : 224
Taille : 1,31 Mo

    voila ton wysiwyg perso et meme pas besoins de connection hein puisque en fait on load le "wig.html qui se trouve sur le bureau et qui vien d'etre créé ainsi que le dossier des images avec les images

    rien ne t'empeche dans l'evenement de fermeture du userform de kill le dossier d'image et le wig.html pas vu pas pris
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  3. #23
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    Super Patrick !

    j'ai juste un problème d'affichage des boutons qui sont "grossiers" car agrandis
    Nom : Capture.PNG
Affichages : 165
Taille : 40,5 Ko
    et je récupère le HTML comme cela :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    UpdatedValue=Me.WebBrowser1.Document.all("editeur").innerHTML
       strHTML = ""
            strHTML = strHTML & "<HEAD>"
            strHTML = strHTML & "<BODY>"
            strHTML = strHTML & UpdatedValue
            strHTML = strHTML & " <BR>"
            strHTML = strHTML & "</BODY>"
            strHTML = strHTML & ""

  4. #24
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    Patrick, y a juste un blèm les boutons gras,etc.. n'ont aucune action lorsque je clique dessus.

    par contre si j'ouvre le doc html via ie cela fonctionne

  5. #25
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    rassure moi tu a bien remis tes cle de registe en ce qui concerne la compatibilité d'origine??
    je vois que ca chez moi ca marche tres bien IE 11 d'origine en mode edge d'origine

    sinon je vois pas
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  6. #26
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut
    n'oublie pas qu'il faut selectionner du texte pour que les bouton fonctionnent
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  7. #27
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    ça marche avec cette modif Meta = Meta & "<!-- saved from url=(0014)about:internet -->"
    = problème de sécurité liée à la zone

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    'rassemblement du code pour ecriture dans un fichier
        Doctype = "<!DOCTYPE html >|"
        Meta = "<html lang=""fr"">|<meta charset=""utf-8"">|"
        Meta = Meta & "<meta http-equiv=""X-UA-Compatible"" content=""IE=11"">|"
        Meta = Meta & "<!-- saved from url=(0014)about:internet -->"
        Code = Doctype & "|<html>|<head>|" & Meta & "|" & CSS & "|" & script & "|</head>|<body onresize=""resizepann()"">|" & ppp & "|</div>|<div id=""editeur"" contenteditable=true><p></p></div>|" & Pa & "|" & Fnn & "|" & Fz & "|</body>|</html>"
        Code = Replace(Code, "|", vbCrLf)

  8. #28
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    OK tu dois avoir parammètré la securité de ton explorateur je vais la mettre pour moi aussi au cas ou
    mais j'ai du mal a comprendre sachant que codée comme ca cette ligne est mise en commentaire non ?

    alors qu'est ce que tu en pense ?? je continue ou pas
    pour les images plus nettes on verra plus tard si je choisi une autre methode
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  9. #29
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    Patrick, ce n'est pas moi qui ai paramétré la sécurité ainsi mais je suis employé par une multinationale avec des actionnaires Anglais et Ricains qui sont très à cheval sur la sécurité, du coup cela complique pas mal de choses !


    Tu peux envoyé le plat de résistance !

  10. #30
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    ok tu en veux encore
    bon ben change le module standard
    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
    Option Explicit
    Const bold = "comd:false:null:bold:113:Texte en gras"
    Const italic = "comd:false:null:italic:114:Mettre le texte de la selection en italic"
    Const underline = "comd:false:null:underline:115:Souligner le texte"
    Const fontName = "listeF:::fontName:1063:Afficher la liste des font name"
    Const fontSize = "listeFZ:::fontSize:1061:Afficher la liste des font size"
    Const foreColor = "palette:::foreColor:1858:Afficher la palette des font color"    'ou 401
    Const backColor = "paletteback:::backColor:1031:Texte avec le Fond en couleur"
    Const indent = "comd:false:null:indent:3161:indenter le texte"
    Const outdent = "comd:false:null:outdent:3162:outdenter le texte"
    Const subscript = "comd:false:null:subscript:333:Mettre en souexposant le texte sélectionné"
    Const superscript = "comd:false:null:superscript:333:Mettre le texte sélectionné en exposant"
    Const copy = "comd:false:null:copy:19:Copier la selection "
    Const cut = "comd:false:null:cut:21:Couper la selection"
    Const paste = "comd:false:true:paste:22:coller"
    Const createLink = "comd:false:null:createLink:1015:Mettre un lien sur la selection"
    Const unlink = "comd:false:null:unlink:1576:Suprimer le lien "
    Const insertHorizontalRule = "comd:false:null:insertHorizontalRule:333:Tirer un trait"
    Const insertOrderedList = "comd:false:null:insertOrderedList:333:insérer ou transformer la selection en liste ordonnée"
    Const insertUnorderedList = "comd:false:null:insertUnorderedList:333:insérer ou transformer la selection en liste non ordonnée"
    Const justifyCenter = "comd:false:null:justifyCenter:122:Centrer le texte"
    Const justifyLeft = "comd:false:null:justifyLeft:120:Aligner le texte a gauche "
    Const justifyRight = "comd:false:null:justifyRight:121:Aligner le texte a droite"
    Const redo = "comd:false:null:redo:333:refaire"
    Const removeFormat = "comd:false:null:removeFormat:108:suprimer le formatage du texte"
    Const strikeThrough = "comd:false:null:strikeThrough:333:Barrer le texte sélectionné"
    Const undo = "comd:false:null:undo:Annuler la dernier operation"
    Const insertimg = "bycommandvba:insertimage::insertimage:682:inserer une image "
    Const html = "afficherhtml:::afficherhtml:109:Afficher le code HTML"
    Const ouvrir = "bycommandvba:ouvrirfichier::Ouvrir:23:Ouvrir un fichier"
    Const imprimer = "comd:false:null:print:4:Imprimer le document"
    Const enregistrer = "bycommandvba:enregistrer::Enregistrer:3:enregistrer le document"
    Const nouveau = "nouveau:::nouveau:2520:Nouveau document"
     
    Sub test()
        Dim CSS As String, Code As String, Doctype As String, Meta As String, arrbout, arrface, x, fichier As String, fN, Bouton, But, i, prop, graf
        Dim script, pann, Fondbout, Bout, r, ppp, pal, c, H, couleur, Pa, Fname, opt, Fnn, Fz, Fsize, inputfich
        Bouton = Array(bold, italic, foreColor, underline, fontName, fontSize, justifyLeft, justifyCenter, justifyRight, indent, outdent, removeFormat, copy, cut, paste, createLink, unlink, insertimg, nouveau, ouvrir, imprimer, enregistrer)
        fN = Array("F-name", "arial", "calibri", "algerian", "arialblack", "aharoni", "baskerville", "comic sans ms", "forte", "georgia", "script")
        'on sauve les image des boutons dans des fichier image solides
        If Dir(Environ("userprofile") & "\Desktop\imageBouton\") = "" Then MkDir Environ("userprofile") & "\desktop\imageBouton"
        Set But = CommandBars(1).Controls.Add(Type:=msoControlButton)
        For i = 0 To UBound(Bouton)
            prop = Split(Bouton(i), ":")
            With But: .FaceId = prop(4): .CopyFace
                With ActiveSheet: Set graf = .ChartObjects.Add(0, 0, 10, 10)
                    graf.Chart.paste
                    graf.Chart.Export Filename:=Environ("userprofile") & "\Desktop\imageBouton\" & prop(3) & ".png"
                    graf.Delete
                End With
            End With
        Next
     
     
        'un peu de style css necessaire a la presentation
        CSS = "<style>||HTML{|  width:100%;|  height:100%;|}|"
        CSS = CSS & "*{|  margin: 0;|  padding: 0;|}|"
        CSS = CSS & "|html{|  width: 100%;|  height: 100%;|  min-height: 100%;|}|"
        CSS = CSS & "|body{|  display: flex; display: -webkit-flex;|  flex-direction:column;|  width: 99%;|  margin: 0.5%;|  height: 99%;|  margin-top:-2px;|  border: 1px solid green;|}|"
        CSS = CSS & "|#panne {|  background: linear-gradient(to right, rgba(247,251,252,1) 0%,rgba(217,237,242,1) 40%,rgba(173,217,228,1) 100%);|  white-space:wrap;|  display:inline -block;|}|"
        CSS = CSS & "|.panlitle{|flex: 0 0 30pt; -webkit-flex: 0 0 40px;|  height: 40px;|}|"
        CSS = CSS & "|.panbig{|flex: 0 0 50pt; -webkit-flex: 0 0 70px;|  height: 70px;|}|"
        CSS = CSS & "|#editeur{| flex: 1 1 auto; -webkit-flex: 1 0 auto;| overflow:auto;| font-size:18px;| border:1px solid gray;|  overflow:auto;|}|"
        CSS = CSS & "|.fondbouton{| display:block;|  background-color:#F2F2F2;|  width:25px;| height:25px;| margin-left:5px;| margin-top:3px;| border:1px solid black;| float:left;| border-radius:7px;|  overflow:hidden;|}|"
        CSS = CSS & "|.bouton{| width:104%;| height:102%;|  margin-left:2px;|}|"
        CSS = CSS & "|.fondbouton:hover {|border:1px solid red;|}|"
        CSS = CSS & "|#palette{| background-color:gray;|  font-size=1px;| display:block;|  width:190px;|  height:170px;position:absolute;|  top:30px;|  left:5px;|  border:1px solid black;|}|"
        CSS = CSS & "|.Bcolor{|  font_size:0px;|  fload:left;|  width:15px;|  height:15px;|  margin-top:0px;|  margin-left:0px;|  border;1px solid black;|}|"
        CSS = CSS & "|#fname{|  position:absolute;|  top:30px;|  left:120px;|}|"
        CSS = CSS & "|#fsize{|  position:absolute;|  top:30px;|  left:145px;|  width:80px;|}|"
        CSS = CSS & "|p{| margin:0|}|"
        CSS = CSS & "|@media print {|  #panne{visibility:hidden;height:0px}|  #editeur{top:0px;border:0px;}|body{border:0px;}|}|"
        CSS = CSS & "|</style>|"
        'la fonction execCommand dans la balise script en javascript
        script = "|<script type=""text/javascript"">|||"
        script = script & "function execCom(fonction, argmt1,argmt2) {|"
        script = script & "   if(argmt1===undefined){argmt1=false;}|"
        script = script & "   if(argmt2===undefined){argmt2=null;}|"
        script = script & "   document.execCommand(fonction,argmt1,argmt2);|"
        script = script & "   var pal=document.getElementById('palette');|   pal.style.visibility=""hidden"";|"
        script = script & "   var L=document.getElementById('fname');|   L.style.visibility=""hidden"";|"
        script = script & "   var fz=document.getElementById('fsize');|   fz.style.visibility=""hidden"";|}|"
        'd'autre fonctions javascript basiques
        script = script & "function palette(mode){|   var pal=document.getElementById(""palette"");|   pal.style.visibility=""visible"";|}|"
        script = script & "function listeF(){|   var L=document.getElementById(""fname"");|   L.style.visibility=""visible"";|}|"
        script = script & "function listeFZ(){|   var L=document.getElementById(""fsize"");|   L.style.visibility=""visible"";|}|"
        script = script & "function resizepann(){| var w = window.outerWidth;|  var pan=document.getElementById(""panne"");|  if(w<750){pan.className=""panbig"";}|  if(w>750){pan.className=""panlitle"";}|}|"
        script = script & "function bycommandvba(argmt){| document.title=argmt;|}|"
        script = script & "function nouveau(){|document.getElementById(""editeur"").innerHTML="""";|}|"
        'suite fonction avenir
        script = script & "|</script>|"
        With CreateObject("htmlfile")
            '---------------------------------------------------------------------------------------------------------
            'creation du ruban et ses boutons
            Set pann = .createelement("DIV"): pann.ID = "panne"
            For i = 0 To UBound(Bouton)
                prop = Split(Bouton(i), ":")
                Set Fondbout = .createelement("DIV")
                Fondbout.classname = "fondbouton"
                Set Bout = .createelement("img")
                With Bout: .ID = prop(3): .Title = prop(5): .classname = "bouton"
                    r = .setAttribute("src", "file://" & Environ("userprofile") & "\Desktop\imageBouton\" & prop(3) & ".png")
                    If prop(0) = "comd" Then .onclick = "execCom('" & prop(3) & "','" & prop(1) & "','" & prop(2) & "')"
                    If prop(0) = "palette" Then .onclick = "palette('ForeColor')"
                    If prop(0) = "listeF" Then .onclick = "listeF('i')"
                    If prop(0) = "listeFZ" Then .onclick = "listeFZ('i')"
                    If prop(0) = "bycommandvba" Then .onclick = "bycommandvba('" & prop(1) & "')"
                    If prop(0) = "nouveau" Then .onclick = "nouveau()"
     
                End With
                Fondbout.appendchild (Bout)
                pann.appendchild (Fondbout)
                pann.classname = "panlitle"
                'MsgBox .Document.getelementbyid(arrbout(i)).outerhtml
            Next
            'recuperation de code outerhtml du ruban(avec ces boutons)
            ppp = pann.outerhtml
            '---------------------------------------------------------------------------------------------------------
            'creation de la palette couleur et ses boutons avec les 56 couleurs d'Excel au format HTML
            Set pal = .createelement("DIV"): pal.ID = "palette": pal.Style.visibility = "hidden"
            For c = 1 To 56
                H = Right("000000" & Hex(ThisWorkbook.Colors(c)), 6)
                couleur = Right(H, 2) & Mid(H, 3, 2) & Left(H, 2)
                Set Bout = .createelement("BUTTON")
                With Bout
                    .Style.backgroundcolor = "#" & couleur
                    .classname = "Bcolor"
                    .onclick = "execCom('ForeColor','false','" & "#" & couleur & "')"
                    pal.appendchild (Bout)
                End With
            Next
            Pa = Replace(pal.outerhtml, "><", ">" & vbCrLf & "<")
            '---------------------------------------------------------------------------------------------------------
            'creation de la liste des font name
            Set Fname = .createelement("SELECT"): Fname.ID = "fname": Fname.Style.visibility = "hidden": Fname.Size = UBound(fN) + 1
            Fname.onchange = "execCom('fontName','false', this.value )"
            For i = 0 To UBound(fN)
                Set opt = .createelement("OPTION"): opt.Value = fN(i): opt.innerhtml = fN(i)
                Fname.appendchild (opt)
            Next
            Fnn = Replace(Fname.outerhtml, "><", ">" & vbCrLf & "<")
            '---------------------------------------------------------------------------------------------------------
            'creation de la liste des font size
            Set Fsize = .createelement("SELECT"): Fsize.ID = "fsize": Fsize.Style.visibility = "hidden": Fsize.Size = 7
            Fsize.onchange = "execCom('fontSize','false', this.value )"
            For i = 1 To 7
                Set opt = .createelement("OPTION"): opt.Value = i: opt.innerhtml = i
                Fsize.appendchild (opt)
            Next
            Fz = Replace(Fsize.outerhtml, "><", ">" & vbCrLf & "<")
        End With
        '---------------------------------------------------------------------------------------------------------
        'rassemblement du code pour ecriture dans un fichier
        Doctype = "<!DOCTYPE html >|"
        Meta = "<html lang=""fr"">|<meta charset=""utf-8"">|"
        Meta = Meta & "<meta http-equiv=""X-UA-Compatible"" content=""IE=11"">|"
        Meta = Meta & "<!-- saved from url=(0014)about:internet -->|"
        inputfich = "<input id=""fichier""  style=""height:0px;""  type=""file"" />"
        Code = Doctype & "|<html>|<head>|" & Meta & "|" & CSS & "|" & script & "|</head>|<body onresize=""resizepann()"">|" & ppp & "|</div>|<div id=""editeur"" contenteditable=true><p></p></div>|" & Pa & "|" & Fnn & "|" & Fz & "|" & inputfich & "|</body>|</html>"
        Code = Replace(Code, "|", vbCrLf)
        'Debug.Print Code
        fichier = Environ("userprofile") & "\Desktop\wig.html"
        x = FreeFile
        Open fichier For Output As #x
        Print #x, Code
        Close #x
        CommandBars(1).Reset
    End Sub
    tu sais que l'acces au fichier en javascript et qu'il est difficile de les manipuler

    et bien je te propose ici de faire l'inverse
    on par de pilotage vba html
    et bien moi je vais te montrer comment faire l'inverse html pilote vba

    et oui le webbroser va demander a vba les boites de dialog que lui ne peut pas faire car cela a été tout simplement supprimé de javascript

    comment me dira tu ?
    c'est simple le webbrowser aussi a des evenement en l'occurence ici un qui repond bien et que l'on utilise tres rarement c'est le "title_change"
    les bouton interne au html vont changer le title
    dans l'evenement vba selon le titre on agira

    alors dans le userform

    tu va ajouter l'evenement
    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
    Private Sub WebBrowser1_TitleChange(ByVal Text As String)
        Dim QuelFichier, x As Integer, lines As String, i As Long
        x = FreeFile
        Select Case Text
        Case "ouvrirfichier"
            QuelFichier = Application.GetOpenFilename(filefilter:="text, *.wig;", Title:="Choisir un ficher", MultiSelect:=False)
            If QuelFichier <> False Then
                Open QuelFichier For Input As #x: lines = Input$(LOF(x), #x): Close #x
                WebBrowser1.Document.getelementbyid("editeur").innerhtml = lines
            End If
        Case "enregistrer"
            QuelFichier = Application.GetSaveAsFilename(InitialFileName:=Environ("userprofile") & "\Desktop", filefilter:="text, *.wig", Title:="ENREGISTREMENT DE LA CAPTURE")
            If QuelFichier <> False Then
                Open QuelFichier For Output As #x: Print #x, WebBrowser1.Document.getelementbyid("editeur").innerhtml: Close #x
            End If
        Case "insertimage"
            QuelFichier = Application.GetOpenFilename(filefilter:="Pictures, *.jpg; *.gif;*.png", Title:="Choisir une image", MultiSelect:=False)
            MsgBox QuelFichier
        End Select
    End Sub
    voila tu a nouveau document (page vierge)
    enregistrer sous (boite de dialog pour enregistrer ce que tu a tapé dans le content editable)avec le format et tout et tout
    et!! le bouton pour ouvrir un fichier que tu a precedement enregistré

    tu peux ainsi créer, ouvrir modifier ,sauver,réouvrir a volonté

    t ' content que je soit passé par la hein

    je fini le bouton insertimage et te le donne des que j'ai fini pour le moment il ne marche pas encore

    ps j'oubliais les fichiers sauvés ont pour extention ".wig"
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  11. #31
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    c'est très ingénieux ! ce que j'aime avec toi c'est que tu explores des voies inconnues ! Mais attention à ton coté obscure ;-)

  12. #32
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re refonte totale du CSS
    bonjour Oliv
    j'ai bossé comme un dingue en meme temps apris beaucoup avec les cadords du forum css et js

    ayant le userform resisable j'ai du apprendre /gouter au CSS3

    voila le resize est parfait
    j'ai ajouter les boutons "liste" aussi

    refonte du module
    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
    Option Explicit
    Const bold = "comd:false:null:bold:113:Texte en gras"
    Const italic = "comd:false:null:italic:114:Mettre le texte de la selection en italic"
    Const underline = "comd:false:null:underline:115:Souligner le texte"
    Const fontName = "listeF:::fontName:1063:Afficher la liste des font name"
    Const fontSize = "listeFZ:::fontSize:1061:Afficher la liste des font size"
    Const foreColor = "palette:::foreColor:1858:Afficher la palette des font color"    'ou 401
    Const backColor = "paletteback:::backColor:1031:Texte avec le Fond en couleur"
    Const indent = "comd:false:null:indent:3161:indenter le texte"
    Const outdent = "comd:false:null:outdent:3162:outdenter le texte"
    Const subscript = "comd:false:null:subscript:333:Mettre en souexposant le texte sélectionné"
    Const superscript = "comd:false:null:superscript:333:Mettre le texte sélectionné en exposant"
    Const copy = "comd:false:null:copy:19:Copier la selection "
    Const cut = "comd:false:null:cut:21:Couper la selection"
    Const paste = "comd:false:true:paste:22:coller"
    Const createLink = "comd:false:null:createLink:1015:Mettre un lien sur la selection"
    Const unlink = "comd:false:null:unlink:1576:Suprimer le lien "
    Const insertHorizontalRule = "comd:false:null:insertHorizontalRule:33:Tirer un trait"
    Const insertOrderedList = "comd:false:null:insertOrderedList:439:insérer ou transformer la selection en liste ordonnée"
    Const insertUnorderedList = "comd:false:null:insertUnorderedList:439:insérer ou transformer la selection en liste non ordonnée"
    Const justifyCenter = "comd:false:null:justifyCenter:122:Centrer le texte"
    Const justifyLeft = "comd:false:null:justifyLeft:120:Aligner le texte a gauche "
    Const justifyRight = "comd:false:null:justifyRight:121:Aligner le texte a droite"
    Const redo = "comd:false:null:redo:333:refaire"
    Const removeFormat = "comd:false:null:removeFormat:108:suprimer le formatage du texte"
    Const strikeThrough = "comd:false:null:strikeThrough:333:Barrer le texte sélectionné"
    Const undo = "comd:false:null:undo:Annuler la dernier operation"
    Const insertimg = "bycommandvba:insertimage::insertimage:682:inserer une image "
    Const html = "afficherhtml:::afficherhtml:109:Afficher le code HTML"
    Const ouvrir = "bycommandvba:ouvrirfichier::Ouvrir:23:Ouvrir un fichier"
    Const imprimer = "comd:false:null:print:4:Imprimer le document"
    Const enregistrer = "bycommandvba:enregistrer::Enregistrer:3:enregistrer le document"
    Const nouveau = "nouveau:::nouveau:2520:Nouveau document"
     
    Sub test2()
        Dim CSS As String, Code As String, Doctype As String, Meta As String, arrbout, arrface, x, fichier As String, fN, Bouton, But, i, prop, graf
        Dim script, pann, Fondbout, Bout, r, ppp, pal, c, H, couleur, Pa, Fname, opt, Fnn, Fz, Fsize, inputfich
        Bouton = Array(bold, italic, foreColor, underline, fontName, fontSize, justifyLeft, justifyCenter, justifyRight, indent, outdent, insertOrderedList, insertUnorderedList, removeFormat, copy, cut, paste, createLink, unlink, insertimg, nouveau, ouvrir, imprimer, enregistrer)
        fN = Array("F-name", "arial", "calibri", "algerian", "arialblack", "aharoni", "baskerville", "comic sans ms", "forte", "georgia", "script")
        'on sauve les image des boutons dans des fichier image solides
        If Dir(Environ("userprofile") & "\Desktop\imageBouton\") = "" Then MkDir Environ("userprofile") & "\desktop\imageBouton"
        Set But = CommandBars(1).Controls.Add(Type:=msoControlButton)
        For i = 0 To UBound(Bouton)
            prop = Split(Bouton(i), ":")
            With But: .FaceId = prop(4): .CopyFace
                With ActiveSheet: Set graf = .ChartObjects.Add(0, 0, 10, 10)
                    graf.Chart.paste
                    graf.Chart.Export Filename:=Environ("userprofile") & "\Desktop\imageBouton\" & prop(3) & ".png"
                    graf.Delete
                End With
            End With
        Next
     
     
        'un peu de style css necessaire a la presentation
        CSS = "|<style>|"
    CSS = CSS & "|html{|  width:100%;|  height:100%;|}|"
    CSS = CSS & "|body{|  display: flex;|  flex-direction: column;|  box-sizing: border-box;|  width:100%;|  height:100%;|  border:1px solid black;|  margin:0;|  padding:0;|  overflow: hidden;|}|"
    CSS = CSS & "|#cadre_cmd{|   padding:3px;|   background: linear-gradient(to right, rgba(247,251,252,1) 0%,rgba(217,237,242,1) 40%,rgba(173,217,228,1) 100%);|    border:1px solid yellow;|}|"
    CSS = CSS & "|#divrouge{|   position: relative;|   flex: 1 0 auto;|   font-size: 0;|   border:1px solid red;|}|"
    CSS = CSS & "|#editeur{|  position: absolute;|  top: 0;|  right: 0;|  bottom: 0;|  left: 0;|  overflow: auto;|  font-size:18px;|  border:1px solid green;|}|"
    CSS = CSS & "|.fondbouton{|   display:block;|  background-color:#F2F2F2;|   width:25px;|   height:25px;|   margin-left:5px;|   margin-top:3px;|   border:1px solid black;|   float:left;|   border-radius:7px;|   overflow:hidden;|}|"
    CSS = CSS & "|.bouton{|   width:104%;|   height:102%;|   margin-left:2px;|}|"
    CSS = CSS & "|.fondbouton:hover {|   border:1px solid red;|}|"
    CSS = CSS & "|#palette{|   background-color:gray;|  font-size=1px;|  display:block;|  width:190px;|  height:170px;position:absolute;|  top:30px;|  left:5px;|  border:1px solid black;|}|"
    CSS = CSS & "|.Bcolor{|  font_size:0px;|  fload:left;|  width:15px;|  height:15px;|  margin-top:0px;|  margin-left:0px;|  border;1px solid black;|}|"
    CSS = CSS & "|#fname{|  position:absolute;|  top:30px;|  left:120px;|}|"
    CSS = CSS & "|#fsize{|  position:absolute;|  top:30px;|  left:145px;|  width:80px;|}|"
    CSS = CSS & "|@media print {|  #cadre_cmd{visibility:hidden;height:0px}|  #editeur{top:0px;border:0px;}|  body{border:0px;}|  #divrouge{border:0px;}|}|"
    CSS = CSS & "|p{|   margin:0;|}|"
    CSS = CSS & "|</style>|"
    CSS = Replace(CSS, "|", vbCrLf)
     
    'les script en javascript
        script = "|<script type=""text/javascript"">|||"
        script = script & "function execCom(fonction, argmt1,argmt2) {|"
        script = script & "   if(argmt1===undefined){argmt1=false;}|"
        script = script & "   if(argmt2===undefined){argmt2=null;}|"
        script = script & "   document.execCommand(fonction,argmt1,argmt2);|"
        script = script & "   var pal=document.getElementById('palette');|   pal.style.visibility=""hidden"";|"
        script = script & "   var L=document.getElementById('fname');|   L.style.visibility=""hidden"";|"
        script = script & "   var fz=document.getElementById('fsize');|   fz.style.visibility=""hidden"";|}|"
        'd'autre fonctions javascript basiques
        script = script & "function palette(mode){|   var pal=document.getElementById(""palette"");|   pal.style.visibility=""visible"";|}|"
        script = script & "function listeF(){|   var L=document.getElementById(""fname"");|   L.style.visibility=""visible"";|}|"
        script = script & "function listeFZ(){|   var L=document.getElementById(""fsize"");|   L.style.visibility=""visible"";|}|"
        script = script & "function resizepann(){| var w = window.outerWidth;|  var pan=document.getElementById(""panne"");|  if(w<750){pan.className=""panbig"";}|  if(w>750){pan.className=""panlitle"";}|}|"
        script = script & "function bycommandvba(argmt){| document.title=argmt;|}|"
        script = script & "function nouveau(){|document.getElementById(""editeur"").innerHTML="""";|}|"
        'suite fonction avenir
        script = script & "|</script>|"
        With CreateObject("htmlfile")
            '---------------------------------------------------------------------------------------------------------
            'creation du ruban et ses boutons
            Set pann = .createelement("DIV"): pann.ID = "cadre_cmd"
            For i = 0 To UBound(Bouton)
                prop = Split(Bouton(i), ":")
                Set Fondbout = .createelement("DIV")
                Fondbout.classname = "fondbouton"
                Set Bout = .createelement("img")
                With Bout: .ID = prop(3): .Title = prop(5): .classname = "bouton"
                    r = .setAttribute("src", "file://" & Environ("userprofile") & "\Desktop\imageBouton\" & prop(3) & ".png")
                    If prop(0) = "comd" Then .onclick = "execCom('" & prop(3) & "','" & prop(1) & "','" & prop(2) & "')"
                    If prop(0) = "palette" Then .onclick = "palette('ForeColor')"
                    If prop(0) = "listeF" Then .onclick = "listeF('i')"
                    If prop(0) = "listeFZ" Then .onclick = "listeFZ('i')"
                    If prop(0) = "bycommandvba" Then .onclick = "bycommandvba('" & prop(1) & "')"
                    If prop(0) = "nouveau" Then .onclick = "nouveau()"
     
                End With
                Fondbout.appendchild (Bout)
                pann.appendchild (Fondbout)
                pann.classname = "panlitle"
                'MsgBox .Document.getelementbyid(arrbout(i)).outerhtml
            Next
            'recuperation de code outerhtml du ruban(avec ces boutons)
            ppp = pann.outerhtml
            '---------------------------------------------------------------------------------------------------------
            'creation de la palette couleur et ses boutons avec les 56 couleurs d'Excel au format HTML
            Set pal = .createelement("DIV"): pal.ID = "palette": pal.Style.visibility = "hidden"
            For c = 1 To 56
                H = Right("000000" & Hex(ThisWorkbook.Colors(c)), 6)
                couleur = Right(H, 2) & Mid(H, 3, 2) & Left(H, 2)
                Set Bout = .createelement("BUTTON")
                With Bout
                    .Style.backgroundcolor = "#" & couleur
                    .classname = "Bcolor"
                    .onclick = "execCom('ForeColor','false','" & "#" & couleur & "')"
                    pal.appendchild (Bout)
                End With
            Next
            Pa = Replace(pal.outerhtml, "><", ">" & vbCrLf & "<")
            '---------------------------------------------------------------------------------------------------------
            'creation de la liste des font name
            Set Fname = .createelement("SELECT"): Fname.ID = "fname": Fname.Style.visibility = "hidden": Fname.Size = UBound(fN) + 1
            Fname.onchange = "execCom('fontName','false', this.value )"
            For i = 0 To UBound(fN)
                Set opt = .createelement("OPTION"): opt.Value = fN(i): opt.innerhtml = fN(i)
                Fname.appendchild (opt)
            Next
            Fnn = Replace(Fname.outerhtml, "><", ">" & vbCrLf & "<")
            '---------------------------------------------------------------------------------------------------------
            'creation de la liste des font size
            Set Fsize = .createelement("SELECT"): Fsize.ID = "fsize": Fsize.Style.visibility = "hidden": Fsize.Size = 7
            Fsize.onchange = "execCom('fontSize','false', this.value )"
            For i = 1 To 7
                Set opt = .createelement("OPTION"): opt.Value = i: opt.innerhtml = i
                Fsize.appendchild (opt)
            Next
            Fz = Replace(Fsize.outerhtml, "><", ">" & vbCrLf & "<")
        End With
        '---------------------------------------------------------------------------------------------------------
        'rassemblement du code pour ecriture dans un fichier
        Doctype = "<!DOCTYPE html >|"
        Meta = "<html lang=""fr"">|<meta charset=""utf-8"">|"
        Meta = Meta & "<meta http-equiv=""X-UA-Compatible"" content=""IE=11"">|"
        Meta = Meta & "<!-- saved from url=(0014)about:internet -->|"
        inputfich = "<input id=""fichier""  style=""height:0px;""  type=""file"" />"
        Code = Doctype & "|<html>|<head>|" & Meta & "|" & CSS & "|" & script & "|</head>|<body>|" & ppp & "|</div>|<div id=divrouge> <div id=""editeur"" contenteditable=true><p></p></div></div>|" & Pa & "|" & Fnn & "|" & Fz & "|" & inputfich & "|</body>|</html>"
        Code = Replace(Code, "|", vbCrLf)
        'Debug.Print Code
        fichier = Environ("userprofile") & "\Desktop\wig.html"
        x = FreeFile
        Open fichier For Output As #x
        Print #x, Code
        Close #x
        CommandBars(1).Reset
    End Sub
    dans le userform j'ai limité le resize a 260
    et on appelle la sub test2 maintenant
    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
    Option Explicit
    Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function fwa Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Sub UserForm_Activate()
        Dim handle
        test2
        handle = fwa(vbNullString, Me.Caption): SetWindowLongA handle, -16, &H94CF0080
        With WebBrowser1: .Silent = True: .Navigate Environ("userprofile") & "\Desktop\wig.html": End With
         UserForm_Resize
    End Sub
    Private Sub UserForm_Resize()
        If Me.height < 30 Then Exit Sub
        If Me.width < 260 Then Me.width = 260
        If Me.height < 260 Then Me.height = 260
        With WebBrowser1: .width = Me.InsideWidth - 1: .height = Me.InsideHeight - 1: End With
    End Sub
     
    Private Sub WebBrowser1_TitleChange(ByVal Text As String)
        Dim QuelFichier, x As Integer, lines As String, i As Long
        x = FreeFile
        Select Case Text
        Case "ouvrirfichier"
            QuelFichier = Application.GetOpenFilename(filefilter:="text, *.wig;", Title:="Choisir un ficher", MultiSelect:=False)
            If QuelFichier <> False Then
                Open QuelFichier For Input As #x: lines = Input$(LOF(x), #x): Close #x
                WebBrowser1.Document.getelementbyid("editeur").innerhtml = lines
            End If
        Case "enregistrer"
            QuelFichier = Application.GetSaveAsFilename(InitialFileName:=Environ("userprofile") & "\Desktop", filefilter:="text, *.wig", Title:="ENREGISTREMENT DE LA CAPTURE")
            If QuelFichier <> False Then
                Open QuelFichier For Output As #x: Print #x, WebBrowser1.Document.getelementbyid("editeur").innerhtml: Close #x
            End If
        Case "insertimage"
            QuelFichier = Application.GetOpenFilename(filefilter:="Pictures, *.jpg; *.gif;*.png", Title:="Choisir une image", MultiSelect:=False)
            MsgBox QuelFichier
        End Select
    End Sub
    c'est vraiment plus clean le resize
    j'attends tes retours de test
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  13. #33
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    Bonjour Patrick,
    J'ai fait quelques tests rapides, BRAVO, c'est efficace.

  14. #34
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    merci oliv
    et il a encore evolué depuis hiers
    alors est ce que ca correspondrait est ce que tu souhaite?
    y a t il un bouton avec une action particuliere que tu voudrais ?
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  15. #35
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    La source html

  16. #36
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 379
    Points : 12 075
    Points
    12 075
    Billets dans le blog
    8
    Par défaut re
    je pofine le css pour les evenement aparition disparition de palette couleur liste etc.....

    je plante sur insertimg aussi
    je reviens tout a l'heure
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

Discussions similaires

  1. tomcat n'affiche pas les pages jsp
    Par bassam0205 dans le forum Tomcat et TomEE
    Réponses: 0
    Dernier message: 20/11/2007, 10h34
  2. Pseudo frames : n'affiche pas certaines pages
    Par mxsmaximus dans le forum Langage
    Réponses: 4
    Dernier message: 01/08/2007, 21h48
  3. N'affiche pas la page index.php
    Par toddy_101 dans le forum Apache
    Réponses: 17
    Dernier message: 02/05/2007, 18h42
  4. [EasyPHP] Local web n'affiche pas la page index.php
    Par pierrot10 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 3
    Dernier message: 15/08/2006, 16h21
  5. sans erreur, apache n'affiche pas la page
    Par dejiein dans le forum Apache
    Réponses: 1
    Dernier message: 01/08/2006, 18h28

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