AndyP
AndyP

Reputation: 21

Creating a multipage at runtime crashes excel

I'd like to create and Multipage object in Excels VBA at runtime. This shouldn't be a problem, normally.

_First, the code:

Set objMPage = UI.frmOutput.Controls.Add( _
                    "Forms.Multipage.1", _
                    "mpgInteractions", _
                    False)

_What are those objects?

UI is a userform, frmOutput is a Frame

_What goes wrong? The code as stated above results in excel crushing for unknown reasons. If, however, the Multipage is created just on the Userform, no error occurs. So, this code:

Set objMPage = UI.Controls.Add( _
                    "Forms.Multipage.1", _
                    "mpgInteractions", _
                    False)

works.

Sadly, I need the Multipage inside the Frame and hope someone can help me with this issue.

Upvotes: 1

Views: 925

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149335

Like I mentioned it works for me.

This is the code that I tried.

Option Explicit

Private Sub CommandButton1_Click()
    Dim objMPage As MultiPage

    Set objMPage = frmOutput.Controls.Add( _
                    "Forms.Multipage.1", _
                    "mpgInteractions", _
                    True)

End Sub

and this is the output

enter image description here

Upvotes: 4

Related Questions