Search code examples
vbapowerpoint

Create image in multipage


I would like to create the image in the multipage in the run time, but it's coming into the userform, below of multipage.

Private Sub UserForm_Initialize()
If MultiPage1.value = 0 Then
    Set lblBtn = Me.Controls.Add("Forms.Image.1")
    With lblBtn
        .Top = 20
        .Left = 40
        .Name = "lblNew1"
    End With
    MsgBox "New Image Control Added"
    MsgBox "Page1 is active"
End If
End Sub

Solution

  • Please, try this replacing

    Set lblBtn = Me.Controls.Add("Forms.Image.1")
    

    with

    Set lblBtn = Me.MultiPage1.Pages(0).Controls.aDD("Forms.Image.1")
    

    Besides that, it would be good to properly declare your variable:

    Dim lblBtn As MSForms.Image