Add an Open File Dialogue Box to a Form
The final control to add is not in the toolbox by default, you have to add it as an extra. This control is the Open File Dialogue Box. However, you'll only be able to add this control if you have the 32 Bit version of Windows. For 64 Bit versions, the Open File Dialogue Box Control is no longer available. You can still add an Open File dialogue box, though, and you'll see how to do this in a later section. But follow along with the steps below to see if the control is there. (Don't worry if it's not. Just move on to the next section.)
To add one to your toolbox, from the menu at the top of the VBA Editor, click on Tools
. From the Tools menu, select Additional Controls
:
When you click on Additional Controls
you should see a dialogue box appear. Scroll down until you come to Microsoft Common Dialog Controls
:
Check the box next to Microsoft Common Dialog Controls
and click OK. You should then see the new controls in the toolbox. Select the Open File dialogue box, circled in the image below:
Draw one out somewhere at the bottom your form and it should look like this:
The dialogue box control is not a visible control. What that means is that when you run your form, you won't see it anywhere. The sole purpose of this control is to manipulate dialogue boxes. You'll see how it works when we write the code for it later.
The only property we'd like to change for this control is the Name
property. Change it from the default CommonDialog1
to CD1
, which is a bit shorter.
And that's the form designed – we can now start coding.