It's been about 20 years since I programmed in VBA and I am having a problem populating a listbox on a user form.
I have a couple of macros I run that I have put on the toolbar in Word 2013. I need to import them to Word 2016 on a Mac, but the option to customize the toolbar isn't available. So, I need to create a macro menu that I can use to call the various options.
I have created a user form with a single list box control. When I run the macro the form appears but the control is empty. I have tried every way imaginable to populate the form, but when I run the code I get the form with an empty list box.
Here is my current iteration for just the simple task of putting the rows on the list box. MainMenu is the form, MainMenuList is the listbox. I have tried multiple options for the sub name including _Initialize and a nonambiguous name with no options such as MainSub. Nothing works. I even tried MainMenu_Click() and clicked on the listbox and form, but no go.
Code:
Option Explicit
Private Sub MainMenu_Load()MainMenuList.AddItem "Books"
MainMenuList.AddItem "Censuses"
End Sub
I will then use the list to call up another form with another list of items to work with. The code beyond that point works fine, but how do I get the menus to work?
I've been able to emulate this using command buttons, but with a census every 10 years from 1790 to 1940, that's a lot of buttons to code. I have been searching and coding for two days and have not found anything to help me create a menu.
Any suggestions?