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
|
Option Explicit
Public collect As Collection
Sub créa_pack()
'Création Variable
Dim Obj As OLEObject
Dim Cl As Classe1
Dim i As Integer, Y As Integer
Dim largeur As Single, hauteur As Single, PH As Long, PG As Long
Dim destcell As Range, Val As String, cell As Range
i = 1
'boucle création bouton
For Each cell In Range("PackId[ID]")
'destination bouton
Set destcell = Worksheets("Facturation").Cells(7, 6 + i)
'val est le nom du pack
Val = cell.Offset(0, 1).Value
'taille cellule
largeur = Columns(destcell.Column).Width
PG = Columns(destcell.Column).Left
hauteur = Rows(destcell.Row).Height
PH = Rows(destcell.Row).Top
Set Obj = Worksheets("Facturation").OLEObjects.Add("Forms.CommandButton.1", Left:=PG, Top:=PH, Width:=largeur, Height:=hauteur)
With Obj
.Name = "Pack" & " " & Val
.Object.Caption = "Pack" & " " & Val
End With
'ajout de l'objet dans la classe (c'est ici que le probleme ce situe*surement)
Set collect = New Collection
Set Cl = New Classe1
Set Cl.ChkBx = Obj.Object
collect.Add Cl
i = i + 1
Next cell
'Worksheets("Facturation").Protect
End Sub |
Partager