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
|
Option Explicit
Public WithEvents Bouton As MSForms.CommandButton
Public WithEvents fram As MSForms.Frame
Public WithEvents framW As MSForms.Frame
Public WithEvents listeB As MSForms.ListBox
Public WithEvents Lab As MSForms.Label
Public WithEvents combo As MSForms.ComboBox
Public WithEvents formm As UserForm
Dim cls(200) As New classe1
Dim cll As New classe1
Dim clCOMB(3) As New classe1
Dim cllB(25) As New classe1
Public Sub Inits(uf)
Set maform = uf
Dim Nb As Integer, Ctrl As Control, nbl As Integer, s As Integer
Dim objCommandBarButton As CommandBarButton
For Each Ctrl In maform.Controls
If TypeName(Ctrl) = "CommandButton" Then
Ctrl.Tag = Ctrl.Caption
Nb = Nb + 1
Set cls(Nb).Bouton = Ctrl
Set cls(Nb).fram = Ctrl.Parent
Set cls(Nb).formm = uf
ElseIf TypeName(Ctrl) = "Label" And Ctrl.Parent.Name = "Frame6" Then ' on met dans la classe uniquement les label qui servent de bouton au wysiwyg
nbl = nbl + 1
Set cllB(nbl).Lab = Ctrl
Set cllB(nbl).framW = Ctrl.Parent
End If
Next
Set cll.listeB = uf.ListBox1
'integration du face id des boutons
Set objCommandBarButton = CommandBars(1).Controls.Add(Type:=msoControlButton)
For Each Ctrl In uf.Frame6.Controls
If TypeName(Ctrl) = "Label" Then Ctrl.Top = 2
If Ctrl.Tag <> "" Then
objCommandBarButton.FaceId = Ctrl.Tag
Ctrl.Picture = objCommandBarButton.Picture
Ctrl.BorderColor = vbWhite
'Ctrl.BackColor = 13434879
' &HFFC0C0
'16577745
End If
Next
Set objCommandBarButton = Nothing
CommandBars(1).Reset
'incrustation du code basic html de l'editeur
With uf.Frame4.WebBrowser1
.Width = uf.Frame4.Controls("Tscript").Width: .Height = uf.Frame4.Controls("Tscript").Height
.Navigate "about:blank"
.Silent = True
.document.Write uf.Frame4.Controls("Tscript").Value
.Silent = True
.Refresh
Do: DoEvents: Loop While .ReadyState <> 4 Or .Busy
End With
'remplissage de la combo des sizeset integration dans la classe
For s = 1 To 7: uf.combosize.AddItem s: Next
Set clCOMB(1).combo = uf.combosize
' remplissage de la combofont et integration dans la classe
uf.combofont.List = Array("arial", "arroni", "arial black", "algerian", "comic sans ms", "castellar", "broadway bt")
Set clCOMB(2).combo = uf.combofont
End Sub
Public Sub Bouton_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Bouton.Parent.Name <> "Frame6" And Bouton.Parent.Tag <> Bouton.Name And Bouton.Parent.Tag <> "" Then
With maform.Controls(fram.Tag): .backcolor = &H404040: .ForeColor = vbWhite: .Caption = .Tag: End With
End If
With Bouton: .backcolor = &HC0C0C0: .ForeColor = vbRed: .Font.bold = True: .Caption = UCase(.Caption): End With
Bouton.Parent.Tag = Bouton.Name
End Sub
Public Sub fram_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If fram.Tag <> "" Then
With maform.Controls(fram.Tag): .backcolor = &H404040: .ForeColor = vbWhite: .Font.bold = False: .Caption = .Tag: End With
End If
If fram.Name = "Frame4" Then fram.ListBox1.Height = 12: fram.ListBox1.Top = 12
End Sub
Private Sub ListeB_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
listeB.Height = 50: listeB.Top = 2
End Sub
Private Sub combo_Click()
Select Case combo.Name
Case "combosize"
If combo.ListIndex <> 0 Then execom "Fontsize", , combo.Value
combo.ListIndex = 0
Case "combofont"
If combo.ListIndex <> 0 Then execom "Fontname", , combo.Value
combo.ListIndex = 0
End Select
End Sub
Private Sub Bouton_Click()
Dim c, i
Bouton.backcolor = vbYellow
Bouton.ForeColor = vbBlue
Select Case Bouton.Name
Case "regexpediteur": Sheets("acceuil").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0) = fram.Emetteur
Case "menu_expediteur": menuexpdesti "exp"
Case "menu_destinataire": menuexpdesti "dest"
Case "param": parametre.Show 0
Case "liste_devis": menudevfac ("E2")
Case "liste_facture": menudevfac ("E3")
Case "regdestinataire"
reg_destinataire.Show 0
reg_destinataire.TextBox8 = fram.destinataire
Case "envoyer"
If maform.destinataire <> "" Then
EnvoiMail_CDO
maform.destinataire = ""
maform.titre = ""
Else:
MsgBox "entrez un destinataire"
End If
Case "appercu_mess"
Dim message
appercu.Show 0
message = paragraphe
'on créé une page vierge dans le web broser
appercu.WebBrowser1.Navigate "about:<html><body></body></html>"
appercu.Controls("WebBrowser1").document.writeln message
Case "supp_P"
For i = fram.ListBox1.ListCount - 1 To 0 Step -1
If fram.ListBox1.Selected(i) Then fram.ListBox1.RemoveItem (i)
Next
Case "CommandButton3"
appercu.Show 0
message = paragraphe
'on créé une page vierge dans le web broser
appercu.WebBrowser1.Navigate "about:<html><body></body></html>"
appercu.Controls("WebBrowser1").document.writeln message
Case "autrefichier": cherchefichier form_email.ListBox1
End Select
End Sub
' bouton de la classe du wysiwyg
Public Sub Lab_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'If Lab.Parent.Tag <> Lab.Name And Lab.Parent.Tag <> "" Then
' With maform.Controls(Lab.Parent.Tag): .BorderColor = vbWhite: End With
' End If
'Lab.Parent.Tag = Lab.Name
'With Lab: .BorderColor = &H80000006:: End With
If framW.suit.Visible = False Then framW.suit.Visible = True
form_email.Frame6.suit.Left = Lab.Left - 1
End Sub
Public Sub framW_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'If framW.Tag <> "" Then
' With maform.Controls(framW.Tag): .BorderColor = vbWhite: End With
'End If
If framW.suit.Visible = True Then framW.suit.Visible = False
End Sub
Private Sub Lab_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Lab.BorderColor = vbWhite
End Sub
Private Sub Lab_Click()
Select Case Lab.Name
Case "bold": execom "bold"
Case "italic": execom "italic"
Case "underline": execom "underline"
Case "strike": execom "Strikethrough"
Case "FONTCOLOR": barrecouleur "FONTCOLOR"
Case "backcolor": barrecouleur "BACKCOLOR"
Case "linck": execom "createLink", False
Case "unlinck": execom "unlink"
Case "justifyleft": execom "justifyleft"
Case "justifycenter": execom "justifycenter"
Case "justifyright": execom "justifyright"
Case "insertorderedlist": execom "insertorderedlist"
Case "insertunorderedlist": execom "insertunorderedlist"
Case "Undo": form_email.WebBrowser1.document.execcommand "undo"
Case "Redo": execom "redo"
Case "sized": form_email.combosize.DropDown
Case "fonta": form_email.combofont.DropDown
End Select
End Sub
Sub execom(commande, Optional argument1 As Boolean = False, Optional argument2 As Variant = Null)
form_email.Frame4.WebBrowser1.document.execcommand commande, argument1, argument2
End Sub 'evenement clic sur bouton wysiwyg
Sub barrecouleur(mode)
Dim str0 As String, str As String, oldcouleur As String, mabarre As Object, bout As Object, pal As Object, couleur As String, divactif As Object
Cells(1, 1).Select
oldcouleur = ActiveCell.Font.Color
On Error Resume Next
Application.CommandBars("palette").Delete
On Error GoTo 0
Set mabarre = Application.CommandBars.Add(Name:="palette", Position:=msoBarPopup)
Set bout = mabarre.Controls.Add(Type:=msoControlButton)
With bout
.Enabled = False
.Caption = mode
End With
Set pal = mabarre.Controls.Add(ID:=1927)
mabarre.ShowPopup
Application.CommandBars("palette").Delete
couleur = ActiveCell.Font.Color
str0 = Right("000000" & Hex(couleur), 6)
str = Right(str0, 2) & Mid(str0, 3, 2) & Left(str0, 2)
couleur = "#" & str & ""
Select Case mode
Case "FONTCOLOR"
execom "forecolor", False, couleur
Case "BACKCOLOR"
execom "backcolor", False, couleur
' si un div interne a été selectionné!!!!
End Select
ActiveCell.Font.Color = oldcouleur
End Sub
Sub cherchefichier(listeB)
Dim fd As FileDialog
ChDir "c:\"
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.InitialFileName = Environ("USERPROFILE") & "\"
Dim vrtSelectedItem As Variant
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
listeB.AddItem vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With
Set fd = Nothing
End Sub |
Partager