1

Question: I have a form I created in Excel (Developer mode). The form has a MutliPage control on it. I am able to add a dynamically add new Page to the multipage control with VBA. I have no idea how to add any content onto this page that I have just created - for example adding a new checkbox, labels etc.

The only code I have at the moment is:

DataQueryForm.DimensionTabs.Pages.Add "MyName", "My Caption"
Dim currentPage As Page
Set currentPage = DataQueryForm.DimensionTabs.Pages(0) 'this line fails

As you can see I don't even know how to get the first Page into a variable of type Page - so it's hard to know how to begin.

Any pointers in how to add new checkboxes to the page would be most appreciated. I'm really struggling to find decent documentation on this, really, anything at this stage would be helpful.

Thanks

1 Answer 1

2

You need to specify MSForms.Page so you don't get a type mismatch (Excel also has a Page object) and you can set the variable as you add the page:

Dim currentPage As MSForms.Page
Set currentPage = DataQueryForm.Dimensiontabs.Pages.Add("MyName", "My Caption")
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, thanks! And then I have access to Controls.Add method. currentPage.Controls.Add("Forms.CheckBox.1", "cmd1")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.