Complément (Vba Indenter Interface)

Complément (Vba Indenter Interface) V 3.1 CFx 2

patricktoulon

XLDnaute Barbatruc
tu es sur de ne pas avoir un autre indenter en même temps
par ce que ton resultat n'est pas logique
j'ajoute 4 espace pour indenter +le len du trim du mot choisi en l’occurrence "Declare"
ça fait pas trois kilomètre d'espace que tu me montre
 

patricktoulon

XLDnaute Barbatruc
re
quand je regarde le html on vois bien que je ne rajoute pas autant d'espace
j'en rajoute 2 pour être exact
HTML:
<PRE indent="-1"><P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="0">Option Compare Text</P>
<DIV typ="BlocdieseIf" indent="0"><P style="MARGIN: 0px" typ2="modul" typ="first" indent="0">#If VBA7 Then</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare PtrSafe Function EnumWindows Lib "user32" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal lpEnumFunc As LongPtr, ByVal Param As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare PtrSafe Function IsWindowVisible Lib "user32" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal hwnd As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare PtrSafe Function EnumDisplayMonitors Lib "user32" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As LongPtr, dwData As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="first" indent="0">#Else</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare Function EnumWindows Lib "user32" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal lpEnumFunc As Long, ByVal Param As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare Function IsWindowVisible Lib "user32" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal hwnd As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Declare Function EnumDisplayMonitors Lib "user32" _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;(ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long</P>
<P style="MARGIN: 0px" typ2="modul" typ="first" indent="0">#End If</P></DIV>
<P style="MARGIN: 0px" typ2="modul" typ="Dim" indent="0">Dim Results As Dictionary</P>
<P style="MARGIN: 0px" typ2="modul" typ="Dim" indent="0">Dim Criteria As String</P>
<DIV typ="BlocSub" indent="0"><P style="MARGIN: 0px" typ2="modul" typ="first" indent="0">Sub Msg_Verrue()</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;UserConfirm _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"Proposition pour le nom du concours du jour : " &amp; _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Format(Now, "DDMMYYYY") &amp; "_" &amp; Environ("COMPUTERNAME"), , _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"vous pouvez faire Ctrl+v (coller)", _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"dans la zone ", _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"""Tapez ici le nom de votre nouveau concours""", _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"de Gc_Concours", , _</P>
<P style="MARGIN: 0px" typ2="modul" typ="autre" indent="1">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;"OK", "IMG"</P>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="first" indent="0">End Sub</P></DIV>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P>
<P style="MARGIN: 0px" typ2="modul" typ="vide" indent="0"></P></PRE>
 

fanch55

XLDnaute Barbatruc
1715757569571.png


J'ai testé le VBE avec le courrier(turk) mais c'est identique au courrier(occidental)
1715757914705.png


Police de ta textbox2 :
1715758332467.png


J'ai exporté en HTML (Je te joins le fichier HTML si cela peux t'aider) :
1715758775491.png


Sinon un dump du copier coller de la textbox2:
1715759413965.png



Bon courage !!!!
 

Pièces jointes

  • code vba _Zone_DévColor.zip
    6.9 KB · Affichages: 1

fanch55

XLDnaute Barbatruc
Et dans le genre "j'en veux plus" ;)
Y a-t-il un moyen d'avoir le même tri dans la liste des modules ( pour ceux qui ont du VB bien sûr 🤗🥴 )
C'est déjà un excellent boulot ....
1715760189652.png
1715760231862.png
 

patricktoulon

XLDnaute Barbatruc
re
bonjour et merci @fanch55
c'est le htmlBrut qu'il me faut( l'autre bouton html)
le htmlcolor c'est pas le html produit par le code brut
c'est un arrangement avec coloration syntaxique pour le partage sur forum dans balise enrichi

le html brut lui me donne les blocs réels DIV: p,p,...DIV et le vrai nombre de "&npsp;"
 

patricktoulon

XLDnaute Barbatruc
re
pour la liste je ne sais pas
elle st tout simplement par ordre alpha dans le vbe
je rajoute un simple petit tri à bulle dans le listemodule et le tour est joué
 

patricktoulon

XLDnaute Barbatruc
que penserais tu si je fesais un raise sur l'indentation des declare function coupées par un underscore

c'est a dire au lieu de choisir une limite en fonction du texte je formaliserais le truc avec un ecart identique pour toutes
du genre à la place de ca(ici je suis indenté au mot"Function")+l'espace
VB:
#If VBA7 Then
    Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                                     (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare PtrSafe Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As LongPtr, ByVal Param As Long) As Long
    Private Declare PtrSafe Function IsWindowVisible Lib "user32" _
                                     (ByVal hwnd As Long) As Long
    Declare PtrSafe Function EnumDisplayMonitors Lib "user32" _
                             (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As LongPtr, dwData As Long) As Long
#Else
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                     (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As Long, ByVal Param As Long) As Long
    Declare Function IsWindowVisible Lib "user32" _
                     (ByVal hwnd As Long) As Long
    Declare Function EnumDisplayMonitors Lib "user32" _
                     (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long
#End If
je fesais ceci
VB:
#If VBA7 Then
    Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                             (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare PtrSafe Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As LongPtr, ByVal Param As Long) As Long
    Private Declare PtrSafe Function IsWindowVisible Lib "user32" _
                             (ByVal hwnd As Long) As Long
    Declare PtrSafe Function EnumDisplayMonitors Lib "user32" _
                             (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As LongPtr, dwData As Long) As Long
#Else
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                             (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As Long, ByVal Param As Long) As Long
    Declare Function IsWindowVisible Lib "user32" _
                             (ByVal hwnd As Long) As Long
    Declare Function EnumDisplayMonitors Lib "user32" _
                             (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long
#End If
qu'en pense tu ?
 

fanch55

XLDnaute Barbatruc
que penserais tu si je fesais un raise sur l'indentation des declare function coupées par un underscore

c'est a dire au lieu de choisir une limite en fonction du texte je formaliserais le truc avec un ecart identique pour toutes
du genre à la place de ca(ici je suis indenté au mot"Function")+l'espace
VB:
#If VBA7 Then
    Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                                     (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare PtrSafe Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As LongPtr, ByVal Param As Long) As Long
    Private Declare PtrSafe Function IsWindowVisible Lib "user32" _
                                     (ByVal hwnd As Long) As Long
    Declare PtrSafe Function EnumDisplayMonitors Lib "user32" _
                             (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As LongPtr, dwData As Long) As Long
#Else
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                     (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As Long, ByVal Param As Long) As Long
    Declare Function IsWindowVisible Lib "user32" _
                     (ByVal hwnd As Long) As Long
    Declare Function EnumDisplayMonitors Lib "user32" _
                     (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long
#End If
je fesais ceci
VB:
#If VBA7 Then
    Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                             (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare PtrSafe Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As LongPtr, ByVal Param As Long) As Long
    Private Declare PtrSafe Function IsWindowVisible Lib "user32" _
                             (ByVal hwnd As Long) As Long
    Declare PtrSafe Function EnumDisplayMonitors Lib "user32" _
                             (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As LongPtr, dwData As Long) As Long
#Else
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
                             (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function EnumWindows Lib "user32" _
                             (ByVal lpEnumFunc As Long, ByVal Param As Long) As Long
    Declare Function IsWindowVisible Lib "user32" _
                             (ByVal hwnd As Long) As Long
    Declare Function EnumDisplayMonitors Lib "user32" _
                             (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long
#End If
qu'en pense tu ?
Ta proposition est de bon aloi,
mais tu auras ( dans les 2 cas) un décalage entre les private et absence de private .
Mais il faut bien trancher un jour ...
 

fanch55

XLDnaute Barbatruc
re
bonjour et merci @fanch55
c'est le htmlBrut qu'il me faut( l'autre bouton html)
le htmlcolor c'est pas le html produit par le code brut
c'est un arrangement avec coloration syntaxique pour le partage sur forum dans balise enrichi

le html brut lui me donne les blocs réels DIV: p,p,...DIV et le vrai nombre de "&npsp;"
Voilà le Brut
 

Pièces jointes

  • code vba _Zone_DévBrut.zip
    5.8 KB · Affichages: 2

patricktoulon

XLDnaute Barbatruc
re
bon ben quand je regarde ton html brut obtenu sans même aller voir le code
on se rend compte que c'est bon on est bien indenté au "Lib"+l'espace
1715767399270.png



et quand je regarde les espace html(&npsp;")
on voit qu'il y a une meprise entre les espace chr(32) et les espaces html(&nbsp;)
1715767625887.png


autrement dit ton vba n'interprète pas les nbsp; du innertext comme des espaces
tu ne fait pas la conversion automatique
pourtant avec ton lecteur binnaire ils le sont (et dans mon vbe aussi)c'est bien tous des 20%
1715767817413.png


conclusion soit tu a un soucis avec ça quelque part
soit alors il y a une option qui gère ce truc quelque par qui n'est pas activée qui chez moi l'est par défaut
 

fanch55

XLDnaute Barbatruc
1715774950083.png

Je compte 90 espaces dans la première continuation.
Je ne pense pas que ce soit mon système ou excel qui les rajoute .

J'ai fait du pas à pas dans la sub Indentcode :
For i = 0 To ps.Length - 1
If i = 3 Then Stop
If checkprogression Then barprogress.curs.Width = (260 / ps.Length) * (i + 1): barprogress.Repaint
On Error Resume Next
SpaC = Application.Rept("&nbsp;&nbsp; &nbsp;", Val(ps(i).getattribute("indent")))
Err.Clear: On Error GoTo 0
ps(i).innerhtml = SpaC & ps(i).innerhtml
ps(i).Style.margin = 0
SpaC = Application.Rept(" ", Application.Max(plusx, 0))
ps(i).innerhtml = SpaC & ps(i).innerhtml
'pour le report d'indentation des Lignes coupées par le "_" ;calcul du Spac
If Right(Trim(ps(i).innertext), 1) = "_" Then
If plusx = 0 Then
plusx = InStr(Trim(ps(i).innertext), "Declare") - 1
If plusx <= 0 Then plusx = InStr(Trim(ps(i).innertext), Chr(34)) - 1
If plusx <= 0 Then plusx = InStr(Trim(ps(i).innertext), " ")
End If
Else
plusx = 0
End If
res2 = res2 & ps(i).outerhtml & vbCrLf

ReS = ReS & SpaC & ps(i).innertext & vbCrLf

Next

Prenons le ps(2) :
"Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _"
InStr(Trim(ps(i).innertext), "Declare") - 1 ==> Plusx = 0
InStr(Trim(ps(i).innertext), Chr(34)) - 1 ==> Plusx = 43 ( le chr34 étant la double quote devant user32)


On passe au ps(3) :
"(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long"
Application.Rept("&nbsp;&nbsp; &nbsp;", Val(ps(i).getattribute("indent"))) => spac = ( 4 espaces )
ps(i).innerhtml = SpaC & ps(i).innerhtml <= on ajoute 4 espaces devant ps(3)
SpaC = Application.Rept(" ", Application.Max(plusx, 0)) <= plusx étant = 43
ps(i).innerhtml = SpaC & ps(i).innerhtml <= on ajoute 43 espaces devant ps(3)

ReS = ReS & SpaC & ps(i).innertext & vbCrLf <= le spac n'a pas changé, on rajoute donc 43 espaces devant ps(3)


Donc 43 + 43 + 4 = 90 espaces ( ce qui vérifie donc ce qui est présenté dans textbox2 à la première indentation )
 

patricktoulon

XLDnaute Barbatruc
re a non
le spac c'est un espace * par la valeur de l'attribut indent de la balise p(ps(x)
il est renouvelé a chaque P
bon de toute façon j'ai tranché
1 dans la version 2.0 DE je bloque a 25 espaces + l'indentation du bloc parent
dans la 3.0 on aura le choix dans les paramètres
2 j'ai revu tout le code pour cette partie je différencie bien le SpaCeHtml et le SpaCeText
3 j'ai ajouté les blocs type et private type (je les avais oublié ceux là )
4 pour la liste; les modules de type 1 sont dans l'ordre
il y a un peu les Feuil qui viennent foutre le wohy mais bon
la flemme de faire deux boucle pour les modules de type 1 et 3 et 2

la version 2.0 DE à télécharger
 

Statistiques des forums

Discussions
312 765
Messages
2 091 873
Membres
105 084
dernier inscrit
lca.pertus