Why Create dialog Boxes

Some of the VBA macros you create behave the same every time you execute them. For example, you may develop a macro that enters a list of your employees into a worksheet range. This macro always produces the same result and requires no additional user input.

You might develop other macros, however, that behave differently under various circumstances or that offer the user options. In such cases, the macro may benefit from a custom dialog box. A custom dialog box provides a simple means for getting information from the user. Your macro then uses that information to determine what it should do.

Custom dialog boxes can be quite useful, but creating them takes time. Before I cover the topic of creating custom dialog boxes in the next chapter, you need to know about some time-saving alternatives.

VBA lets you display four different types of dialog boxes that you can sometimes use in place of a custom dialog box. You can customize these built-in dialog boxes in some ways, but they certainly don't offer the options available in a custom dialog box. In some cases, however, they're just what the doctor ordered.

In this chapter you read about

1 The MsgBox function 1 The InputBox function i The GetOpenFileName method i The GetSaveAsFileName method

I also describe how to use VBA to display the Excel built-in dialog boxes — the dialog boxes that Excel itself uses to get information from you.

Was this article helpful?

0 0

Post a comment