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
| Public WithEvents Oopt As MSForms.OptionButton
Public WithEvents Ooptbis As MSForms.OptionButton
Public WithEvents Ocheck As MSForms.CheckBox
Public WithEvents Ocheckbis As MSForms.CheckBox
Public usf As Object
Dim cls(300) As New interface
Function init_interface(uf)
Set plagetitre = Sheets(1).Range("A2", Cells(2, Columns.Count).End(xlToLeft))
cat = ""
For Each cel In plagetitre.Cells
catg = cel.MergeArea.Cells(1).Text
If catg <> cat And catg <> "" Then
'Debug.Print cel.MergeArea.CurrentRegion.Address
cat = catg
Set Page = uf.MultiPage1.Pages.Add
i = i + 1: Page.Caption = "categorie" & i
With Page: .ControlTipText = catg: .Tag = cel.MergeArea.CurrentRegion.Address:
Set labtitre = .Controls.Add("Forms.Label.1", "toto", True)
With labtitre: .Caption = catg: .ForeColor = &H800000: .Width = Page.Parent.Width: .Font.Size = 12: .Font.Bold = True: .TextAlign = 2: End With '
Set fram = .Controls.Add("Forms.Frame.1", "F" & .Caption, True)
With fram: .Caption = "": .Width = Page.Parent.Width: .Height = Page.Parent.Height - 50: .Top = 30: .ScrollBars = 2: .BackColor = &HE0E0E0 '
End With
End With
End If
Next
For Each p In uf.MultiPage1.Pages
With p
Set plage = Sheets(1).Range(.Tag)
Set fram = uf.Controls("F" & .Caption)
fram.ScrollHeight = (plage.Columns.Count * 40) + 5
Debug.Print plage.Address
AA = 0
For c = plage.Column To plage.Column + plage.Columns.Count - 1
AA = AA + 1
li = (40 * (AA - 1)) + 5
x = x + 1
Set cls(x).usf = uf
'Debug.Print Sheets(1).Cells(3, c).Text
Set lab = fram.Controls.Add("Forms.Label.1", True)
With lab: .BorderStyle = 0: .Caption = Sheets(1).Cells(3, c).Text: .ForeColor = &H800000: .Left = 2: .Width = 250: .Font.Size = 10: .Height = 35: .Top = li: End With '
Set opt1 = fram.Controls.Add("Forms.optionbutton.1", "opti" & x, True): Set cls(x).Oopt = opt1
With opt1: .Tag = c: .Caption = "R": .ForeColor = &H800000: .Left = 270: .Width = 30: .Font.Size = 12: .Top = lab.Top - 5: End With '
Set check = fram.Controls.Add("Forms.checkbox.1", "check" & x, True): Set cls(x).Ocheck = check
With check: .Tag = c: .Caption = "": .ForeColor = &H800000: .Left = 350: .Width = 250: .Font.Size = 12: .Top = lab.Top - 8: End With '
Set checkbis = fram.Controls.Add("Forms.checkbox.1", "checkbis" & x, True): Set cls(x).Ocheckbis = checkbis
With checkbis: .Tag = c: .Caption = "": .ForeColor = &H800000: .Left = 350: .Width = 250: .Font.Size = 12: .Top = lab.Top + 10: End With '
Set opt2 = fram.Controls.Add("Forms.optionbutton.1", True): Set cls(x).Ooptbis = opt2:
With opt2: .Tag = c: .Caption = "T": .ForeColor = &H800000: .Left = 300: .Width = 30: .Font.Size = 12: .Top = lab.Top - 5: End With '
Set separ = fram.Controls.Add("Forms.Label.1", True)
With separ: .Caption = "": .BorderStyle = 0: .BackColor = &HC0C0C0: .Left = 0: .Width = .Parent.Width: .Height = 2: .Top = li + 30: End With '
Next
End With
Next
End Function
Private Sub oopt_Click()
Ocheck.Caption = Sheets(1).Cells(5, Val(Oopt.Tag)).Text
Ocheckbis.Caption = Sheets(1).Cells(6, Val(Oopt.Tag)).Text
usf.ListBox1.AddItem Sheets(1).Cells(4, Val(Oopt.Tag)).Text
'MsgBox Sheets(1).Cells(5, Val(Oopt.Tag)).Text & vbCrLf & Sheets(1).Cells(6, Val(Oopt.Tag)).Text
End Sub
Private Sub ooptbis_Click()
Ocheck.Caption = Sheets(1).Cells(8, Val(Ooptbis.Tag)).Text
Ocheckbis.Caption = Sheets(1).Cells(9, Val(Ooptbis.Tag)).Text
'MsgBox Sheets(1).Cells(8, Val(Ooptbis.Tag)).Text & vbCrLf & Sheets(1).Cells(9, Val(Ooptbis.Tag)).Text
End Sub
Private Sub Ocheck_Click()
usf.ListBox2.AddItem Sheets(1).Cells(8, Val(Ocheck.Tag)).Text
End Sub
Private Sub Ocheckbis_Click()
usf.ListBox2.AddItem Sheets(1).Cells(9, Val(Ocheck.Tag)).Text
End Sub |