Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Adding controls in a Multipage

  Asked By: Mehndi    Date: Mar 19    Category: MS Office    Views: 820
  

I have a userform with a multipage.
On page 2 of the MP I would like to add by code a collection of labels.

I have the following code:
(mpDonnées is the name of the multipage)
Dim Ctrls As Controls
Dim lbl As Label
Set Ctrls = Me.mpDonnées.Pages(2).Controls
'Label Variables
Set lbl = Ctrls.Add("Forms.Label.1", "lblVariables", True)

The last line give me a Type Incompatibility error.

Can some one help me ?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Felix Gray     Answered On: Mar 19


Try (1) removing:
Dim lbl As Label

or (2) changing it to:
Dim lbl As Object

Why? I dunno, but both worked here! Is 'Label' a different type  of object?

Note that Pages(2) in your code  would refer to a 3rd page  of a
multipage as numbering starts at 0.

 
Didn't find what you were looking for? Find more on Adding controls in a Multipage Or get search suggestion and latest updates.




Tagged: