Excel VBA Macro Programming

Overview

In the Visual Basic language is a Common Dialog control that allows you access to standard Microsoft dialogs for opening files, saving files, printing, selecting color , and selecting font. All the dialogs for these purposes that you see in standard Microsoft applications are yours for the taking to use within your own programs.

There is a complete interface to allow you to choose what dialog to display and to be able to set various parameters to alter the appearance of the dialog to suit the purpose of your program. Even better, you can then retrieve the parameters that the user has selected and have your code act on them accordingly . For example, if the user selects a file to open , you can easily find out the file and pathname, and write the code accordingly.

An important point is that these are only dialogs to provide a common interface to the user. You must still write the code to handle the selections or events that the user chooses; it does not happen automatically. For example, if you display the Save dialog, and the user types a filename and presses OK, nothing will happen unless you have written the code to collect the filename chosen and the code to save the data to that filename.

Microsoft provides an important helping hand here so that you do not have to reinvent the wheel to provide common user interfaces components . However, you still have to do some of the work in selecting the options that will be available on the dialogs and interpreting what to do with the user's selection.

These Common User Interface dialogs work exactly the same as in any Microsoft application, but by manipulating the properties, you can use the values they produce in your code.

Категории