Bonjour à tous et toutes mes compatriotes...
Un petit barbatruc rien que pour vous !!
NB pensez à mettre :
Menu Excel => Outils / Macro Sécurité => 'Source Sûre' (Trusted Source)
=> 'Laisser Acces au Projet Visual Basic' (Trust Access to Visual Basic Project)
Puis copier coller cette macro dans un module vierge standard...
Bien à Vous et Bonne Duvel à Tous et Toutes
@+Thierry
EDITION !!!
Petit Allègement de Code qui conservait des Objects inutiles, que j'avais bien entendu déjà écrit pour un truc plus élaboré...
Merci Mr Spock
Message édité par: _Thierry, à: 21/07/2005 18:20
Un petit barbatruc rien que pour vous !!
NB pensez à mettre :
Menu Excel => Outils / Macro Sécurité => 'Source Sûre' (Trusted Source)
=> 'Laisser Acces au Projet Visual Basic' (Trust Access to Visual Basic Project)
Puis copier coller cette macro dans un module vierge standard...
Option Explicit
Const Sign As String = 'Bonne Fête !! @+Thierry'
Const LblWidth As Integer = 10
Const LblHeigth As Integer = 10
Const LblLeft As Integer = 10
Const LblTop As Integer = 15
Sub AutoBuilder()
Dim ObjUSF As Object
Dim ObjLabel As Object
Dim TopPlusHeight As Integer
Dim x As Byte
Dim VLblLeft As Integer
Dim C As Long, CC As Long
Dim L As String
Set ObjUSF = ThisWorkbook.VBProject.VBComponents.Add(3)
With ObjUSF
.Properties('Caption') = Sign
.Properties('Width') = 168
.Properties('Height') = 158
.Properties('ShowModal') = True
End With
For x = 1 To 120
L = ''
CC = 0
Set ObjLabel = ObjUSF.Designer.Controls.Add('Forms.Label.1')
Select Case x
Case 1 To 10
If x = 1 Then TopPlusHeight = LblTop
VLblLeft = 2 * LblLeft
C = 0
Case 11 To 20
If x = 11 Then TopPlusHeight = LblTop
VLblLeft = 3 * LblLeft
C = 0
Case 21 To 30
If x = 21 Then TopPlusHeight = LblTop
VLblLeft = 4 * LblLeft
C = 0: CC = 65535
If x = 26 Then L = Chr(66)
Case 31 To 40
If x = 31 Then TopPlusHeight = LblTop
VLblLeft = 5 * LblLeft
C = 0:: CC = 65535
If x = 36 Then L = Chr(69)
Case 41 To 50
If x = 41 Then TopPlusHeight = LblTop
VLblLeft = 6 * LblLeft
C = 65535
Case 51 To 60
If x = 51 Then TopPlusHeight = LblTop
VLblLeft = 7 * LblLeft
C = 65535
If x = 56 Then L = Chr(76)
Case 61 To 70
If x = 61 Then TopPlusHeight = LblTop
VLblLeft = 8 * LblLeft
C = 65535
If x = 66 Then L = Chr(71)
Case 71 To 80
If x = 71 Then TopPlusHeight = LblTop
VLblLeft = 9 * LblLeft
C = 65535
If x = 76 Then L = Chr(73)
Case 81 To 90
If x = 81 Then TopPlusHeight = LblTop
VLblLeft = 10 * LblLeft
C = 255
If x = 86 Then L = Chr(81)
Case 91 To 100
If x = 91 Then TopPlusHeight = LblTop
VLblLeft = 11 * LblLeft
C = 255
If x = 96 Then L = Chr(85)
Case 101 To 110
If x = 101 Then TopPlusHeight = LblTop
VLblLeft = 12 * LblLeft
C = 255
If x = 106 Then L = Chr(69)
Case 111 To 120
If x = 111 Then TopPlusHeight = LblTop
VLblLeft = 13 * LblLeft
C = 255
End Select
With ObjLabel
.Caption = L
.ForeColor = CC
.BackColor = C
.Left = VLblLeft: .Top = TopPlusHeight: .Width = LblWidth: .Height = LblHeigth
.Name = 'Thierry' & x
End With
TopPlusHeight = TopPlusHeight + 10
Next
With VBA.UserForms.Add(ObjUSF.Name)
.Show
End With
Set ObjUSF = Nothing
Set ObjLabel = Nothing
End Sub
Bien à Vous et Bonne Duvel à Tous et Toutes
@+Thierry
EDITION !!!
Petit Allègement de Code qui conservait des Objects inutiles, que j'avais bien entendu déjà écrit pour un truc plus élaboré...
Merci Mr Spock
Message édité par: _Thierry, à: 21/07/2005 18:20