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
| Dim UsfObj As Object
Dim L1 As MSForms.Label
Dim Msg As String
Sub CreateUserForm()
Set UsfObj = ThisWorkbook.VBProject.VBComponents.Add(3)
With UsfObj
.Properties("Caption") = "Message d'attente"
.Properties("Left") = 20
.Properties("Top") = 20
.Properties("Width") = 240
.Properties("Height") = 100
End With
Msg = "Traitement en cours" & Chr(10) & "Veuillez patienter"
Set L1 = UsfObj.Designer.Controls.Add("forms.Label.1", "Label1", True)
With L1
.AutoSize = False
.Caption = Msg
.Left = 0
.Top = 0
.Width = 240
.Height = 100
.Name = "Label1"
.Font.Bold = False
.Font.Size = 10
End With
ShowUsf
End Sub
Sub ShowUsf()
UserForm1.Show vbModeless
End Sub
Sub DelUsf()
With ThisWorkbook.VBProject.VBComponents
.Remove .Item("Userform1")
End With
End Sub
Sub TesText()
Msg = "Test"
UserForm1.Label1.Caption = Msg
End Sub |