
上QQ阅读APP看书,第一时间看更新
046 显示常用的Excel内置对话框
Dialogs属性
为了方便用户快速地显示Excel的内置对话框,图1-7中列举了一些常用的内置对话框的VB常量及值。

图1-7 一些常用的内置对话框的VB常量及值
在Excel工作表中插入一个按钮,为其指定一个名为“范例1_046”的宏,宏代码如下:
第1章\范例1-046.xlsm

插入一个窗体,在此窗体中插入一个列表框ListBox1和一个命令按钮CommandButton1,如图1-8所示。为用户窗体设置Initialize事件,为列表框和命令按钮设置Click事件,程序代码分别如下所示。关于如何设计用户窗体及其事件程序,可参阅后面的有关章节。

图1-8 插入列表框和命令按钮
第1章\范例1-046.xlsm

单击工作表上的按钮,打开用户窗体,如图1-9所示,单击列表框中的某个内置对话框,就可以显示该对话框,如图1-10所示。

图1-9 打开用户窗体

图1-10 显示【单元格格式】对话框