VBA自定义菜单如何设置快捷键培训资料

合集下载

VBA中的Excel界面自定义指南

VBA中的Excel界面自定义指南

VBA中的Excel界面自定义指南Excel是一个功能强大的电子表格程序,可以帮助用户处理大量的数据和执行各种运算。

而VBA(Visual Basic for Applications)是Excel的内置编程语言,可以让用户以编程的方式自动化Excel的操作。

在Excel中,用户可以通过自定义界面来优化他们的工作流程,提高工作效率。

本文将重点介绍如何使用VBA自定义Excel界面,以便更好地适应个人需求。

1. 自定义菜单和工具栏Excel的菜单和工具栏提供了许多常用功能和命令,但有时候我们可能需要更多特定于个人需求的功能。

通过VBA,我们可以自定义菜单和工具栏,添加自己定义的命令和功能。

首先,我们需要打开Excel的开发工具。

在Excel的菜单栏上,选择“文件”->“选项”,然后在弹出的对话框中选择“自定义功能区”。

点击“自定义功能区”后,可以看到“主选项卡”和“定制功能区”两栏。

在“定制功能区”中,我们可以添加自定义的菜单和工具栏。

在VBA编辑器中,我们可以使用以下代码来添加自定义的菜单:```vbaSub AddCustomMenu()mandBars("Worksheet MenuBar").Controls.Add(Type:=msoControlPopup,Temporary:=True).Caption = "自定义菜单"With mandBars("Worksheet Menu Bar").Controls("自定义菜单").Controls.Add.Caption = "命令1".Controls.Add.Caption = "命令2"End WithEnd Sub```这段代码会在Excel的菜单栏上添加一个名为“自定义菜单”的菜单,并在该菜单下添加两个命令:“命令1”和“命令2”。

使用VBA创建自定义菜单和工具栏

使用VBA创建自定义菜单和工具栏

使用VBA创建自定义菜单和工具栏在Microsoft Office软件中,自定义菜单和工具栏是提高工作效率的重要工具。

通过使用VBA(Visual Basic for Applications)编程语言,可以轻松创建自定义菜单和工具栏,以满足个人或团队的需求。

在本文中,我将介绍如何使用VBA创建自定义菜单和工具栏,同时提供一些实用的示例来帮助读者了解如何在不同的Office应用程序中应用这些技巧。

首先,在应用程序打开的情况下,打开VBA编辑器。

可以通过按下`Alt + F11`快捷键,或在“开发者”选项卡中点击“Visual Basic”按钮来打开VBA编辑器。

接下来,我们将创建一个自定义菜单。

在VBA编辑器中,点击“插入”菜单,然后选择“模块”,这将创建一个新的代码模块。

在代码模块中,输入以下代码:```Sub CreateCustomMenu()Dim cMenuBar As CommandBarDim cMenu As CommandBarPopup'删除已存在的自定义菜单On Error Resume NextmandBars("Custom Menu").DeleteOn Error GoTo 0'创建新的自定义菜单Set cMenuBar = mandBars.Add(Name:="Custom Menu", _Position:=msoBarTop, MenuBar:=False, Temporary:=True)Set cMenu = cMenuBar.Controls.Add(Type:=msoControlPopup, Temporary:=True)With cMenu.Caption = "Custom Menu"'添加菜单项.Controls.Add(Type:=msoControlButton, Temporary:=True).Caption = "菜单项1".Controls.Add(Type:=msoControlButton, Temporary:=True).Caption = "菜单项2".Controls.Add(Type:=msoControlButton, Temporary:=True).Caption = "菜单项3"End WithEnd Sub```在上面的代码中,我们首先删除已经存在的名为“Custom Menu”的自定义菜单,以确保我们创建的菜单是最新的。

使用VBA自快捷菜单

使用VBA自快捷菜单

使⽤VBA⾃快捷菜单本⽂将展⽰⼀些操作 Excel2007 快捷菜单的 VBA 代码实例,您可以修改这些例⼦以满⾜您的需要。

本⽂中的⼤部分内容也适⽤于Excel以前的版本。

重置快捷菜单Reset⽅法恢复某快捷菜单到其默认状态,例如,下⾯的过程恢复单元格(Cell)快捷菜单到其标准状态:Sub ResetCellMenu() CommandBars("Cell").ResetEnd SubExcel2007有两个名为Cell的快捷菜单,上⾯的代码仅恢复第⼀个(即索引值为38)的Cell快捷菜单。

为恢复第⼆个Cell快捷菜单,使⽤索引值(41)代替其名称。

下⾯的过程恢复所有的内置⼯具栏到其初始状态:Sub ResetAll() Dim cbar As CommandBar For Each cbar In mandBars If cbar.Type = msoBarTypePopup Then cbar.Reset cbar.Enabled = True End If Next cbarEnd Sub注意,如果在您的应⽤程序中添加项⽬到某快捷菜单中,最好在关闭应⽤程序时分别移除这些项⽬。

如果简单地恢复快捷菜单,将会删除由其它应⽤程序所定制的快捷菜单。

禁⽤快捷菜单Enabled属性可以让您禁⽤整个快捷菜单。

例如,可以设置该属性后,在右键单击某单元格时不再显⽰正常的快捷菜单,下⾯的语句禁⽤Cell快捷菜单:PLAIN TEXTVisual Basic:mandBars("Cell").Enabled = False 要重新启⽤该快捷菜单,简单地设置其Enabled属性为True。

如果想要禁⽤所有的快捷菜单,使⽤下⾯的过程:Sub DisableAllShortcutMenus() Dim cb As CommandBar For Each cb In CommandBars If cb.Type = msoBarTypePopup Then _ cb.Enabled = False Next cbEnd Sub注意,禁⽤的快捷菜单将会在所有会话中起作⽤,因此,在关闭Excel之前可能想要恢复快捷菜单。

VBA快捷键

VBA快捷键
Ctrl+% 应用不带小数位的“百分比”格式。
Ctrl+^ 应用带有两位小数的“指数”格式。
Ctrl+# 应用带有日、月和年的“日期”格式。
Ctrl+@ 应用带有小时和分钟以及 AM 或 PM 的“时间”格式。
Ctrl+! 应用带有两位小数、千位分隔符和减号 (-)(用于负值)的“数值”格式。
按 Ctrl+F9 可将工作簿窗口最小化为图标。
F10 选择菜单栏或同时关闭打开的菜单和子菜单。
按 Shift+F10 可显示选定项目的快捷菜单。
按 Alt+Shift+F10 可显示智能标记的菜单或消息。如果存在多个智能标记,按该组合键可切换到下一个智能标记并显示其菜单或消息。
F2 编辑活动单元格并将插入点放在单元格内容的结尾。如果禁止在单元格中进行编辑,它也会将插入点移到编辑栏中。
按 Shift+F2 可编辑单元格批注。
F3 将定义的名称粘贴到公式中。
按 Shift+F3 将显示“插入函数”对话框。
F4 重复上一个命令或操作(如有可能)。
按 Ctrl+F4 可关闭选定的工作簿窗口。
按 Ctrl+F10 可最大化或还原选定的工作簿窗口。
F11 创建当前范围内数据的图表。
按 Shift+F11 可插入一个新工作表。
按 Alt+F11 将打开 Visual Basic 编辑器,您可以在其中通过使用 Visual Basic for Applications (VBA) 来创建宏。
按 Ctrl+空格键可选择工作表中的整列。
按 Shift+空格键可选择工作表中的整行。

VBA中的快捷键设置与应用技巧

VBA中的快捷键设置与应用技巧

VBA中的快捷键设置与应用技巧VBA(Visual Basic for Applications)是一种用于进行自动化操作的编程语言,常用于Microsoft Office软件中,如Word、Excel、PowerPoint等。

它可以帮助用户通过编写宏来提高工作效率和减少重复性操作。

在VBA中,设置和使用快捷键是一个非常实用的技巧,可以进一步提高工作效率。

本文将介绍VBA中的快捷键设置与应用技巧,帮助读者更好地利用VBA进行自动化操作。

一、设置自定义的快捷键在VBA中,通过设置自定义的快捷键,可以方便地执行特定的操作。

下面是设置自定义快捷键的步骤:1. 打开VBA编辑器:在需要设置快捷键的Office软件中,按下“Alt +F11”键,即可打开VBA编辑器。

2. 选择代码窗口:在VBA编辑器中,选择你需要设置快捷键的模块或代码窗口。

3. 打开属性窗口:在VBA编辑器的“视图”菜单中,选择“属性窗口”选项,即可打开属性窗口。

4. 设置快捷键:在属性窗口中,找到“名称”属性,双击该属性,即可编辑快捷键。

输入你想要的快捷键组合,如Ctrl+Shift+P。

5. 编写VBA代码:在代码窗口中,编写你想要执行的VBA代码。

例如,你可以编写一个用于插入当前日期的代码。

6. 关闭VBA编辑器:保存你的VBA代码,并关闭VBA编辑器。

现在,你可以使用你设置的快捷键组合来执行相应的操作。

按下你设置的快捷键时,VBA代码将会被执行,完成相应的任务。

二、常用的快捷键技巧除了设置自定义的快捷键,VBA中还有一些常用的快捷键技巧,可以帮助用户更高效地进行编程和操作。

1. 执行代码:在VBA编辑器的代码窗口中,按下“F5”键,即可执行当前选中的VBA代码。

这对于测试代码和调试程序非常有用。

2. 注释代码:在VBA编辑器的代码窗口中,选中需要注释的代码,然后按下“Ctrl + Shift + C”键,即可将选中的代码添加注释。

VBA菜单和工具栏定制技巧

VBA菜单和工具栏定制技巧

VBA菜单和工具栏定制技巧VBA(Visual Basic for Applications)是一种强大的编程语言,可以集成到Microsoft Office套件中,帮助用户自定义功能和加强应用程序的自动化。

在Microsoft Office中,菜单和工具栏是我们经常使用的功能,通过VBA的定制技巧,我们可以根据自己的需求自定义菜单和工具栏,提高工作效率和用户体验。

本文将介绍一些VBA菜单和工具栏定制的技巧,帮助用户快速掌握这一强大的功能。

一、自定义菜单1. 添加自定义菜单项在VBA编辑器中,我们可以使用“CustomMenus”对象添加自定义菜单项。

首先,打开VBA编辑器(Alt + F11),然后在左侧的项目浏览器中选择对应的工作簿。

接下来,右键点击工作簿名称,在弹出的菜单中选择“插入”→“模块”。

在新建的模块中,输入以下代码:```vbaSub AddCustomMenuItem()CommandBars("Worksheet menu bar").Controls("自定义菜单").Controls.Add Type:=msoControlButton, before:=2CommandBars("Worksheet menu bar").Controls("自定义菜单").Controls(1).Caption = "自定义菜单项"End Sub```该代码将在工作表的菜单栏中添加一个名称为“自定义菜单”的菜单,并在菜单中添加一个名称为“自定义菜单项”的菜单项。

2. 添加快捷键要给自定义菜单项添加快捷键,可以使用以下代码:```vbaSub AddShortcutKey()CommandBars("Worksheet menu bar").Controls("自定义菜单").Controls(1).OnAction = "CustomMenuItem_Click"CommandBars("Worksheet menubar").FindControl(ID:=30010).ShortcutText = "Ctrl+Shift+C"End SubSub CustomMenuItem_Click()' 自定义菜单项的功能代码End Sub```在上述代码中,“CustomMenuItem_Click”是自定义菜单项的点击事件处理程序,用户可以通过修改这一事件处理程序的代码来实现所需的功能。

VBA实现自定义菜单与工具栏的步骤与技巧

VBA实现自定义菜单与工具栏的步骤与技巧

VBA实现自定义菜单与工具栏的步骤与技巧自定义菜单和工具栏是VBA中非常有用的功能,能够提供更加灵活和高效的用户界面。

通过自定义菜单和工具栏,我们可以根据自己的需求添加或删除菜单项和工具按钮,使得用户能够方便地访问所需的功能。

本文将介绍如何使用VBA实现自定义菜单与工具栏的步骤与技巧。

一、创建自定义菜单要创建自定义菜单,首先需要打开Visual Basic编辑器(VBE),然后按下ALT+F11快捷键。

在VBE中,选择“插入” -> “用户窗体”或者右键单击项目资源管理器中的该工作簿并选择“插入模块”。

在新的用户窗体或模块中,输入以下代码,以创建一个名为"CustomMenu"的自定义菜单。

```vbaSub CreateCustomMenu()Dim cBar As CommandBarDim cBarControl As CommandBarControl' 如果已经存在名称为"CustomMenu"的菜单,则删除它On Error Resume NextmandBars("CustomMenu").DeleteOn Error GoTo 0' 创建自定义菜单Set cBar = mandBars.Add(Name:="CustomMenu", Position:=msoBarPopup, _MenuBar:=False, Temporary:=True)' 添加菜单项Set cBarControl = cBar.Controls.Add(Type:=msoControlButton)With cBarControl.Caption = "菜单项1".OnAction = "Macro1"End WithSet cBarControl = cBar.Controls.Add(Type:=msoControlButton)With cBarControl.BeginGroup = True.Caption = "菜单项2".OnAction = "Macro2"End WithEnd SubSub Macro1()' 菜单项1的宏代码End SubSub Macro2()' 菜单项2的宏代码End Sub```在创建的自定义菜单中,我们通过`CommandBar`对象和`CommandBarControl`对象来创建和添加菜单项。

Excel VBA编程 自定义快速访问工具栏

Excel VBA编程  自定义快速访问工具栏

Excel VBA编程自定义快速访问工具栏对于一些常用的命令按钮,如果用户需要将其放置到Excel的一个明显位置,如放置到【自定义快速访问】工具栏中,并使其单击即可使用。

此时,只需单击Office按钮,并单击【Excel 选项】命令,在弹出的对话框中,选择【自定义】选项卡。

然后,在【从下列位置选择命令】下拉列表中,选择【所有命令】选项,并在其下方的列表中,查找到所需的按钮或命令,如选择【记录单】选项,单击【添加】按钮。

此时,用户可以在其右侧的列表中,观察到【记录单】选项已被添加到该列表中,如图1-6所示。

图1-6 添加按钮图1-7 添加【记录单】按钮单击【确定】按钮,即可将【记录单】按钮添加到快速访问工具栏中,如图1-7所示。

用户只需单击添加到快速访问工具栏中的按钮即可使用。

技巧右击功能区的空白处,或者右击功能区上的按钮,执行【自定义快速访问工具栏】命令,也可以打开【Excel 选项】对话框。

其中,在【Excel 选项】对话框中的【自定义】选项卡中,包含多个选项,其功能如下:●从下列位置选择命令单击该选项下方的下拉按钮,在其下拉列表中,用户可以选择相应的选项,如选择常用命令、宏、Office 菜单、开始选项卡等选项。

选择相应的选项后,在其下方的列表中,可以选择相应的选项。

●在功能区下方显示快速访问工具栏默认情况下,快速访问工具栏被显示在功能区的上方,用户可以通过启用【在功能区下方显示快速访问工具栏】复选框,来更改其位置至功能区的下方。

●自定义快速访问工具栏单击该下拉按钮,在其下拉列表中,包含两项内容,分别为用于所有文档(默认)和当前活动的工作添加表(如用于“工程进度.xlsx”工作表)。

●【添加】按钮单击该按钮,即可将此按钮左侧被选择的选项,添加到右侧的列表中,从而添加到快速访问工具栏中。

●【删除】按钮单击该按钮,即可将此按钮右侧被选择的选项进行删除。

●【重设】按钮单击该按钮,则无论在快速访问工具栏中添加了多少个按钮,都会还原到默认的保存、恢复和撤消3个按钮。

VBA快捷键的设置和使用方法

VBA快捷键的设置和使用方法

VBA快捷键的设置和使用方法VBA是一种颇为强大的编程语言,通过使用VBA,您可以自动化执行各种任务,并加快在Excel等Microsoft Office应用程序中的工作效率。

为了进一步提高您的工作效率,本文将介绍VBA的快捷键设置和使用方法,帮助您更加便捷地使用VBA。

一、什么是快捷键?快捷键是指通过按下组合键或单独按下某个键来执行特定的功能或命令。

利用快捷键可以在不使用鼠标的情况下,更快地完成任务。

在VBA中设置和使用快捷键可以让您更加高效地编写代码和操作Excel。

二、设置VBA快捷键的方法1. 打开VBA编辑器要设置VBA快捷键,首先需要打开VBA编辑器。

在Excel中,按下“Alt + F11”即可进入VBA编辑器界面。

2. 打开“宏命令”对话框在VBA编辑器中,选择“工具”菜单,然后点击“宏命令”选项,或者直接使用快捷键“Alt + F8”,即可打开“宏命令”对话框。

3. 选择宏在“宏命令”对话框中,会显示您已经录制过的宏。

选择您需要设置快捷键的宏,并点击“选项”按钮。

4. 设置快捷键在“选项”对话框中,您可以选择一个未被占用的键位作为快捷键。

点击“快捷键”文本框,并按下您想要设置的组合键或单独按下某个键,然后点击“确定”按钮。

5. 保存设置设置完快捷键后,点击“确定”按钮,然后点击“关闭”按钮,关闭VBA编辑器。

接下来,您可以在Excel中使用设置好的快捷键。

三、常用的VBA快捷键以下是一些常用的VBA快捷键,它们可以帮助您更加高效地编写代码和操作Excel:1. 运行宏:按下“F5”键,或者使用快捷键“Ctrl + Shift + P”。

通过此快捷键,您可以运行当前打开的宏,从而执行相应的任务。

2. 停止宏:按下“Ctrl + Break”键。

在开发过程中,如果由于某种原因需要停止宏的执行,您可以按下“Ctrl + Break”键来停止宏的运行。

3. 调试模式:按下“Ctrl + Break”或“Ctrl + Pause”键。

VBA中的菜单与工具栏自定义

VBA中的菜单与工具栏自定义

VBA中的菜单与工具栏自定义VBA(Visual Basic for Applications)是一种用于编写自定义宏和脚本的编程语言,可以与多种应用程序集成,例如Microsoft Excel、Word和PowerPoint等。

在VBA中,可以通过自定义菜单和工具栏来增加应用程序的功能和用户体验。

本文将介绍如何在VBA中进行菜单与工具栏的自定义,以及一些常用的技巧和注意事项。

1. 自定义菜单VBA中可以使用CommandBar对象来创建和管理菜单。

首先,我们需要创建一个CommandBar对象,然后向其添加按钮和子菜单项。

创建菜单的代码如下:```Sub CreateMenu()Dim menuBar As ObjectDim newMenu As Object' 检查是否已存在自定义菜单,若存在则删除For Each menuBar In mandBarsIf = "CustomMenu" ThenmenuBar.DeleteEnd IfNext menuBar' 创建一个自定义菜单Set menuBar = mandBars.Add(Name:="CustomMenu", Position:=msoBarTop)menuBar.Visible = True' 添加按钮和子菜单项Set newMenu = menuBar.Controls.Add(Type:=msoControlPopup)newMenu.Caption = "菜单1"newMenu.Controls.Add(Type:=msoControlButton).Caption = "按钮1"newMenu.Controls.Add(Type:=msoControlButton).Caption = "按钮2"' 添加分隔线menuBar.Controls.Add(Type:=msoControlSeparator)menuBar.Controls.Add(Type:=msoControlButton).Caption = "按钮3"' 设置快捷键newMenu.Controls("按钮1").OnAction = "Macro1"newMenu.Controls("按钮2").OnAction = "Macro2"menuBar.Controls("按钮3").OnAction = "Macro3"End Sub```通过以上代码,我们创建了一个名为"CustomMenu"的自定义菜单,并在菜单中添加了三个按钮,分别执行名为"Macro1"、"Macro2"和"Macro3"的宏。

Excel VBA自定义菜单和菜单栏

Excel VBA自定义菜单和菜单栏

Excel VBA自定义菜单和菜单栏(江羽收集整理)【目录】前言 (3)一、简介 (3)二、命令栏 (4)三、控件常量 (4)四、菜单栏 (6)4.1A DD方法应用于C OMMAND B ARS对象 (6)4.2返回命令栏控件的ID (7)4.3确定活动菜单栏的名称 (7)4.4保存(内置或自定义菜单栏的)活动状态 (8)4.5创建自定义命令栏 (8)4.6显示自定义命令栏 (8)4.7删除自定义命令栏 (9)4.8隐藏命令栏 (9)4.9显示命令栏 (9)4.10还原内置命令栏 (9)五、菜单 (10)5.1A DD方法用于C OMMAND B AR C ONTROLS对象 (10)5.2向命令栏添加自定义菜单控件 (11)5.3禁用命令栏上的菜单控件 (11)5.4启用命令栏上的菜单控件 (11)5.5删除命令栏上的菜单控件 (12)5.6还原命令栏上的菜单控件 (12)六、命令 (12)6.1向菜单控件添加分隔条 (13)6.2在菜单上创建自定义命令控件 (13)6.3在命令控件旁放置选中标记 (13)6.4禁用命令栏上的命令控件 (14)6.5启用命令栏上的命令控件 (14)6.6删除菜单上的命令控件 (15)6.7还原菜单上的内置命令控件 (15)七、子菜单 (15)7.1添加子菜单 (16)7.2向子菜单添加命令 (16)7.3禁用子菜单上的命令控件 (16)7.4删除子菜单上的命令 (17)7.5禁用子菜单控件 (17)7.6删除子菜单控件 (17)八、快捷菜单栏 (18)8.1新建快捷菜单栏 (18)九、快捷菜单 (19)9.1在快捷菜单栏上创建命令 (19)9.2禁用快捷菜单栏上的命令控件 (19)9.3删除快捷菜单栏上的命令 (20)9.4删除快捷菜单栏 (20)9.5还原内置快捷菜单栏上的命令 (20)十、快捷菜单上的子菜单 (20)10.1在快捷菜单栏上新建子菜单 (21)10.2在快捷菜单栏的子菜单上创建命令控件 (21)10.3禁用快捷菜单上的子菜单项控件 (22)10.4删除快捷菜单上的子菜单项控件 (22)10.5禁用快捷菜单上的子菜单控件 (22)10.6删除快捷菜单上的子菜单控件 (23)前言在EXCEL中,我们的操作都是通过“工具栏、菜单栏、快捷菜”单实现。

VBA 中的命令按钮的使用方法与实例

VBA 中的命令按钮的使用方法与实例

VBA 中的命令按钮的使用方法与实例VBA(Visual Basic for Applications)是一种用于自动化任务和定制应用程序的编程语言。

其中的命令按钮是一种常见的用户界面元素,它允许用户通过单击按钮来执行特定的功能或命令。

在本文中,我们将探讨 VBA 中命令按钮的使用方法与实例。

在 VBA 中使用命令按钮之前,我们首先需要在用户界面(如 Excel 或 Word)中添加一个按钮控件。

您可以通过以下步骤完成此操作:1. 打开您想要添加按钮的应用程序(如 Excel 或 Word)。

2. 在工具栏中选择"开发工具" 选项卡(如果没有,则需要在设置中启用它)。

3. 在 "开发工具" 选项卡中,点击 "插入",然后选择 "按钮" 控件。

4. 在程序界面中按住鼠标左键并拖动光标,绘制按钮的大小和位置。

5. 在绘制按钮的过程中,会自动打开 "分配宏" 窗口。

您可以选择现有的宏或创建新的宏来与按钮关联,以实现特定的功能。

现在,让我们深入了解 VBA 中命令按钮的使用方法与实例。

以下是几个常见的例子:1. 显示消息框:在按钮的点击事件中,您可以使用VBA 的MsgBox 函数来显示消息框。

例如,下面的代码将显示一个简单的消息框,提示用户点击了按钮:```vbaSub Button_Click()MsgBox "按钮被点击了!"End Sub```2. 打开文件对话框:您可以使用 VBA 的 Application.FileDialog 对象来创建一个文件对话框,以便用户选择文件。

以下是一个示例代码:```vbaSub Button_Click()Dim filePath As VariantWith Application.FileDialog(msoFileDialogFilePicker).Title = "选择文件".ShowIf .SelectedItems.Count > 0 ThenfilePath = .SelectedItems(1)MsgBox "您选择的文件是:" & filePathElseMsgBox "您取消了选择文件。

如何使用VBA代码在Excel界面添加自定义菜单

如何使用VBA代码在Excel界面添加自定义菜单

如何使用VBA代码在Excel界面添加自定义菜单'运行该过程后,将在工作表菜单的“帮助”菜单左侧添加一个名为“统计”的新菜单。

'注:要删除新添加的菜单,使用Delete方法即可,例如代码:CommandBars(1).Controls("统计(&S)").Delete'将删除刚创建的“统计”菜单。

'添加菜单项'与添加新菜单一样,在添加菜单项及子菜单时,使用Add方法,且指定合适的控件类型,其代码清单如下:Sub AddNewMenu()Dim HelpMenu As CommandBarControlDim NewMenu As CommandBarPopupDim MenuItem As CommandBarControlDim SubMenuItem As CommandBarButtonOn Error Resume Next'如果菜单已存在,则删除该菜单CommandBars(1).Controls("统计(&S)").Delete'利用ID属性查找帮助菜单Set HelpMenu = CommandBars(1).FindControl(ID:=30010) If HelpMenu Is Nothing Then'如果该菜单不存在,则将新菜单添加到末尾'设置新菜单为临时的Set NewMenu = CommandBars(1).Controls _.Add(Type:=msoControlPopup, Temporary:=True)Else'将新菜单添加到帮助菜单之前Set NewMenu = CommandBars(1).Controls _.Add(Type:=msoControlPopup, Before:=HelpMenu.Index, _ Temporary:=True)End If'添加菜单标题并指定热键NewMenu.Caption = "统计(&S)"'添加第一个菜单项Set MenuItem = NewMenu.Controls.Add _ (Type:=msoControlButton)With MenuItem.Caption = "输入数据(&D)...".FaceId = 162.OnAction = "Macro1"End With'添加第二个菜单项Set MenuItem = NewMenu.Controls.Add _ (Type:=msoControlButton)With MenuItem.Caption = "汇总数据(&T)..."'添加快捷键.ShortcutText = "Ctrl Shift T".FaceId = 590.OnAction = "Macro2"End With'添加第三个菜单项'本菜单有子菜单项,因此其类型为msoControlPopup Set MenuItem = NewMenu.Controls.Add _ (Type:=msoControlPopup)With MenuItem.Caption = "数据报表(&R)..."'添加分隔线.BeginGroup = TrueEnd With'添加子菜单'添加第一个子菜单Set SubMenuItem = MenuItem.Controls.Add(Type:=msoControlButton) With SubMenuItem.Caption = "月汇总(&M)".FaceId = 110.OnAction = "Macro3"End With'添加第二个子菜单Set SubMenuItem = MenuItem.Controls.Add _(Type:=msoControlButton)With SubMenuItem.Caption = "季度汇总(&Q)".FaceId = 222.OnAction = "Macro4"End WithEnd SubSub deleteMenu()CommandBars(1).Controls("统计(&S)").DeleteEnd Sub使用方法:在Workbook_Open() 过程中调用AddNewMenu(),在Workbook_BeforeClose 过程中调用deleteMenu()。

VBA自定义菜单如何设置快捷键

VBA自定义菜单如何设置快捷键

Static Sub AddMenu() '添加自定义菜单Dim NewMenuBar As CommandBarDim CX As CommandBarControl, JC As CommandBarControl, TB As CommandBarControl, SJ As CommandBarControl, BF As CommandBarControlDim DY As CommandBarControl, BZ As CommandBarControl, XX As CommandBarControl, USE As CommandBarControl, WH As CommandBarControl Dim CW As CommandBarControl, TJ As CommandBarControl, LJC As CommandBarControl, YZ2 As CommandBarControl, YJC As CommandBarControl Dim LDQ As CommandBarControl, LNB As CommandBarControl, SDQ As CommandBarControl, SNB As CommandBarControl, LAll As CommandBarControl Dim JSB As CommandBarControl, SAll As CommandBarControl, DDQ As CommandBarControl, DNB As CommandBarControl, CDQ As CommandBarControl Dim CNB As CommandBarControl, C0 As CommandBarControl, CTZ As CommandBarControl, BF1 As CommandBarControl, BF2 As CommandBarControl Dim BF8 As CommandBarControl, DY1 As CommandBarControl, DY2 As CommandBarControl, SM As CommandBarControl, FG As CommandBarControlDim KK As CommandBarControl, Bh1 As CommandBarControl, Bh2 As CommandBarControl, JB1 As CommandBarControl, JB2 As CommandBarControl Dim KB As CommandBarControl, FZ As CommandBarControl, SY As CommandBarControl, CZ As CommandBarControl, Z1 As CommandBarControlDim Z2 As CommandBarControl, NH As CommandBarControl, B1 As CommandBarControl, B2 As CommandBarControl, B3 As CommandBarControl, BD As CommandBarControlDim B5 As CommandBarControl, B6 As CommandBarControl, S1 As CommandBarControl, S2 As CommandBarControl, S3 As CommandBarControlDim S5 As CommandBarControl, S6 As CommandBarControl, D1 As CommandBarControl, D2 As CommandBarControl, D3 As CommandBarControlDim D5 As CommandBarControl, D6 As CommandBarControl, C1 As CommandBarControl, C2 As CommandBarControl, C3 As CommandBarControlDim C5 As CommandBarControl, C6 As CommandBarControl, TJF As CommandBarControl, TL As CommandBarControl, CL As CommandBarControlDim ClCells As CommandBarControl, ShHL As CommandBarControlApplication.ScreenUpdating = FalseOn Error Resume NextMenuBars("MyMenuBar").Delete'定义菜单Set NewMenuBar = CommandBars.Add(MenuBar:=True) = "MyMenuBar"NewMenuBar.Visible = True'定义一级菜单项Set CX = NewMenuBar.Controls.Add(Type:=msoControlPopup) CX.Caption = "程序设置"CX.Visible = TrueSet JC = NewMenuBar.Controls.Add(Type:=msoControlPopup) JC.Caption = "基础数据"JC.Visible = TrueSet TB = NewMenuBar.Controls.Add(Type:=msoControlPopup) TB.Caption = "报表审录"TB.Visible = TrueSet SJ = NewMenuBar.Controls.Add(Type:=msoControlPopup) SJ.Caption = "数据处理"SJ.Visible = TrueSet BF = NewMenuBar.Controls.Add(Type:=msoControlPopup) BF.Caption = "报表备份"BF.Visible = TrueSet DY = NewMenuBar.Controls.Add(Type:=msoControlPopup) DY.Caption = "打印控制"DY.Visible = TrueSet BZ = NewMenuBar.Controls.Add(Type:=msoControlPopup) BZ.Caption = "帮助信息"BZ.Visible = True'定义二级菜单项Set XX = CX.Controls.Add(Type:=msoControlButton) With XX.Caption = "企业信息".OnAction = "ShowXX".FaceId = 1016End WithSet USE = CX.Controls.Add(Type:=msoControlButton) With USE.Caption = "操作设定".OnAction = "UserSet".FaceId = 1980End WithSet TIM = CX.Controls.Add(Type:=msoControlButton) With TIM.Caption = "报表时期".OnAction = "ChangeMonth".BeginGroup = True '菜单选项之间的分隔线End WithSet WH = CX.Controls.Add(Type:=msoControlPopup) With WH.Caption = "报表维护".BeginGroup = True '菜单选项之间的分隔线End WithSet CW = JC.Controls.Add(Type:=msoControlPopup) With CW.Caption = "财务报表"End WithSet TJ = JC.Controls.Add(Type:=msoControlPopup)With TJ.Caption = "统计数据"End WithSet LJC = JC.Controls.Add(Type:=msoControlButton) With LJC.Caption = "基础数据综合录入".BeginGroup = True '菜单选项之间的分隔线.OnAction = "ShowJC".FaceId = 353End WithSet YZ2 = JC.Controls.Add(Type:=msoControlButton) With YZ2.Caption = "增表二数据套用".BeginGroup = True '菜单选项之间的分隔线.OnAction = "CountZ1".FaceId = 211End WithSet YJC = JC.Controls.Add(Type:=msoControlButton) With YJC.Caption = "基础数据导入主表".BeginGroup = True '菜单选项之间的分隔线.OnAction = "CountJC".FaceId = 938End WithSet LDQ = TB.Controls.Add(Type:=msoControlPopup) With LDQ.Caption = "录入定期报表"End WithSet LNB = TB.Controls.Add(Type:=msoControlButton) With LNB.Caption = "录入年报报表".OnAction = "ShowNB" '无.FaceId = 162End WithSet SDQ = TB.Controls.Add(Type:=msoControlPopup) With SDQ.Caption = "定期报表审核".BeginGroup = True '菜单选项之间的分隔线End WithSet SNB = TB.Controls.Add(Type:=msoControlButton) With SNB.Caption = "年报报表审核".OnAction = "CheckNB".FaceId = 172End WithSet JSB = TB.Controls.Add(Type:=msoControlButton) With JSB.Caption = "表间数据计算".OnAction = "CountBB".FaceId = 283.BeginGroup = True '菜单选项之间的分隔线End WithSet LAll = TB.Controls.Add(Type:=msoControlButton) With LAll.Caption = "当期报表通录".BeginGroup = True '菜单选项之间的分隔线.OnAction = "ShowBB".FaceId = 212End WithSet SAll = TB.Controls.Add(Type:=msoControlButton) With SAll.Caption = "当期报表全审".OnAction = "CheckBB".FaceId = 790.BeginGroup = True '菜单选项之间的分隔线End WithSet DDQ = SJ.Controls.Add(Type:=msoControlPopup) With DDQ.Caption = "定期数据导入"End WithSet DNB = SJ.Controls.Add(Type:=msoControlButton) With DNB.Caption = "年报数据导入".OnAction = "InNB".FaceId = 237End WithSet CDQ = SJ.Controls.Add(Type:=msoControlPopup) With CDQ.Caption = "生成定期数据".BeginGroup = True '菜单选项之间的分隔线End WithSet CNB = SJ.Controls.Add(Type:=msoControlButton) With CNB.Caption = "生成年报报表数据".FaceId = 762.OnAction = "OutNB"End WithSet C0 = SJ.Controls.Add(Type:=msoControlButton) With C0.Caption = "生成全部数据".FaceId = 721.OnAction = "OutAll".BeginGroup = True '菜单选项之间的分隔线End WithSet CTZ = SJ.Controls.Add(Type:=msoControlButton) With CTZ.Caption = "生成统计台账".FaceId = 222.OnAction = "OutTZ"End WithSet BF1 = BF.Controls.Add(Type:=msoControlButton) With BF1.Caption = "备份定期报表".FaceId = 356.OnAction = "Copy1"End WithSet BF2 = BF.Controls.Add(Type:=msoControlButton) With BF2.Caption = "备份年报套表".FaceId = 1665.OnAction = "Copy2"End WithSet BF8 = BF.Controls.Add(Type:=msoControlButton) With BF8.Caption = "程序数据表转存".FaceId = 749.OnAction = "CopyAll".BeginGroup = True '菜单选项之间的分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet DY0 = DY.Controls.Add(Type:=msoControlButton) With DY0.Caption = "预览调整".FaceId = 25.OnAction = "Print0"End WithSet DY1 = DY.Controls.Add(Type:=msoControlButton) With DY1.Caption = "打印当前报表".FaceId = 4.OnAction = "Print1"End WithSet SM = BZ.Controls.Add(Type:=msoControlButton) With SM.Caption = "程序说明".FaceId = 984.OnAction = "Help"End WithSet FG = BZ.Controls.Add(Type:=msoControlPopup)With FG.Caption = "统计法规参考".BeginGroup = True '菜单选项之间的分隔线End WithSet BB = BZ.Controls.Add(Type:=msoControlButton)With BB.Caption = "程序版本信息".OnAction = "ShowKK".FaceId = 809.BeginGroup = True '菜单选项之间的分隔线End With'定义三级菜单项Set JB1 = WH.Controls.Add(Type:=msoControlButton) With JB1.Caption = "工作表解锁".FaceId = 916.OnAction = "JB1"End WithSet Bh1 = WH.Controls.Add(Type:=msoControlButton)With Bh1.Caption = "锁定工作表".FaceId = 894.OnAction = "Bh1"End WithSet JB2 = WH.Controls.Add(Type:=msoControlButton)With JB2.Caption = "工作簿解锁".FaceId = 719.OnAction = "JB2".BeginGroup = True '菜单选项之间的分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet Bh2 = WH.Controls.Add(Type:=msoControlButton)With Bh2.Caption = "锁定工作簿".FaceId = 718.OnAction = "Bh2"If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet DelCell = WH.Controls.Add(Type:=msoControlButton) With DelCell.Caption = "清除本月表内数据".FaceId = 20.OnAction = "Clear1".BeginGroup = True '分隔线End WithSet ClCells = WH.Controls.Add(Type:=msoControlButton) With ClCells.Caption = "清除本表所有数据".OnAction = "ClearAll"If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet SHL = WH.Controls.Add(Type:=msoControlButton) With SHL.Caption = "行列编辑信息".FaceId = 11.OnAction = "ShowRC".BeginGroup = True '分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet KB = WH.Controls.Add(Type:=msoControlButton)With KB.Caption = "查阅所有表".FaceId = 8.OnAction = "ShowAll".BeginGroup = True '分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet FZ = CW.Controls.Add(Type:=msoControlButton) With FZ.Caption = "资产负债表".FaceId = 133.OnAction = "ShowFZ"End WithSet SY = CW.Controls.Add(Type:=msoControlButton) With SY.Caption = "损益(利润)表".FaceId = 136.OnAction = "ShowSY"End WithSet CZ = TJ.Controls.Add(Type:=msoControlButton) With CZ.Caption = "总产值计算表".FaceId = 17.OnAction = "ShowCZ".BeginGroup = True '分隔线End WithSet Z1 = TJ.Controls.Add(Type:=msoControlButton) With Z1.Caption = "增加值计算表一".FaceId = 144.OnAction = "ShowZ1"End WithSet Z2 = TJ.Controls.Add(Type:=msoControlButton) With Z2.Caption = "增加值计算表二".FaceId = 144.OnAction = "ShowZ2"End WithSet NH = TJ.Controls.Add(Type:=msoControlButton) With NH.Caption = "能耗记录表".FaceId = 107.OnAction = "ShowNH"End WithSet B1 = LDQ.Controls.Add(Type:=msoControlButton) With B1.Caption = "B201表".FaceId = 483.OnAction = "Show201"End WithSet B2 = LDQ.Controls.Add(Type:=msoControlButton) With B2.Caption = "B202表".FaceId = 481.OnAction = "Show202"End WithSet B3 = LDQ.Controls.Add(Type:=msoControlButton) With B3.Caption = "B203表".FaceId = 484.OnAction = "Show203".BeginGroup = True '分隔线End WithSet B5 = LDQ.Controls.Add(Type:=msoControlButton) With B5.Caption = "P205表".FaceId = 482.OnAction = "Show205"End WithSet B6 = LDQ.Controls.Add(Type:=msoControlButton) With B6.Caption = "P206表".FaceId = 59.OnAction = "Show206".BeginGroup = True '分隔线End WithSet BD = LDQ.Controls.Add(Type:=msoControlButton) With BD.Caption = "乡企定综1表".FaceId = 1763.OnAction = "ShowD1".BeginGroup = True '分隔线End WithSet S1 = SDQ.Controls.Add(Type:=msoControlButton) With S1.Caption = "B201表".FaceId = 329.OnAction = "Check201"End WithSet S2 = SDQ.Controls.Add(Type:=msoControlButton) With S2.Caption = "B202表".OnAction = "Check202"End WithSet S3 = SDQ.Controls.Add(Type:=msoControlButton) With S3.Caption = "B203表".FaceId = 107.OnAction = "Check203".BeginGroup = True '分隔线End WithSet S5 = SDQ.Controls.Add(Type:=msoControlButton) With S5.Caption = "P205表".OnAction = "Check205"End WithSet S6 = SDQ.Controls.Add(Type:=msoControlButton) With S6.Caption = "P206表".FaceId = 1715.OnAction = "Check206".BeginGroup = True '分隔线End WithSet D1 = DDQ.Controls.Add(Type:=msoControlButton) With D1.Caption = "B201表".FaceId = 239.OnAction = "In201".BeginGroup = True '分隔线End WithSet D2 = DDQ.Controls.Add(Type:=msoControlButton) With D2.Caption = "B202表".OnAction = "In202".BeginGroup = True '分隔线End WithSet D3 = DDQ.Controls.Add(Type:=msoControlButton) With D3.Caption = "P203表".FaceId = 317.OnAction = "In203".BeginGroup = True '分隔线End WithSet D5 = DDQ.Controls.Add(Type:=msoControlButton) With D5.Caption = "P205表".OnAction = "In205"End WithSet D6 = DDQ.Controls.Add(Type:=msoControlButton) With D6.Caption = "P206表".FaceId = 271.OnAction = "In206".BeginGroup = True '分隔线End WithSet C1 = CDQ.Controls.Add(Type:=msoControlButton) With C1.Caption = "B201表".FaceId = 538.OnAction = "Out201"End WithSet C2 = CDQ.Controls.Add(Type:=msoControlButton) With C2.Caption = "B202表".OnAction = "Out202"End WithSet C3 = CDQ.Controls.Add(Type:=msoControlButton) With C3.Caption = "B203表".FaceId = 439.OnAction = "Out203".BeginGroup = True '分隔线End WithSet C5 = CDQ.Controls.Add(Type:=msoControlButton) With C5.Caption = "P205表".OnAction = "Out205"End WithSet C6 = CDQ.Controls.Add(Type:=msoControlButton) With C6.Caption = "P206表".FaceId = 270.OnAction = "Out206".BeginGroup = True '分隔线End WithSet TJF = FG.Controls.Add(Type:=msoControlButton) With TJF.Caption = "统计法".FaceId = 463.OnAction = "ShowTJF"End WithSet TL = FG.Controls.Add(Type:=msoControlButton) With TL.Caption = "统计管理条例".FaceId = 942.OnAction = "ShowTL"End WithSet CL = FG.Controls.Add(Type:=msoControlButton) With CL.Caption = "自由裁量权".FaceId = 983.OnAction = "ShowCLQ"End WithApplication.MacroOptions Macro:="show201", HasShortcutKey:=True, ShortcutKey:="1"Application.ScreenUpdating = TrueEnd Sub。

[汇编]VBA快捷键

[汇编]VBA快捷键

VBA快捷键很多,大多数记不住也用不着!常用的通常适合于所有的Windows操作:Ctrl+C Ctrl+V Ctrl+Z Ctrl+Y Ctrl+B等-------------------------------------------------------------------Ctrl 组合快捷键按键说明Ctrl+( 取消隐藏选定范围内所有隐藏的行。

Ctrl+) 取消隐藏选定范围内所有隐藏的列。

Ctrl+& 将外框应用于选定单元格。

Ctrl+_ 从选定单元格删除外框。

Ctrl+~ 应用“常规”数字格式。

Ctrl+$ 应用带有两位小数的“货币”格式(负数放在括号中)。

Ctrl+% 应用不带小数位的“百分比”格式。

Ctrl+^ 应用带有两位小数的“指数”格式。

Ctrl+# 应用带有日、月和年的“日期”格式。

Ctrl+@ 应用带有小时和分钟以及 AM 或 PM 的“时间”格式。

Ctrl+! 应用带有两位小数、千位分隔符和减号 (-)(用于负值)的“数值”格式。

Ctrl+- 显示用于删除选定单元格的“删除”对话框。

Ctrl+* 选择环绕活动单元格的当前区域(由空白行和空白列围起的数据区域)。

在数据透视表中,它将选择整个数据透视表。

Ctrl+: 输入当前时间。

Ctrl+; 输入当前日期。

Ctrl+` 在工作表中切换显示单元格值和公式。

Ctrl+' 将公式从活动单元格上方的单元格复制到单元格或编辑栏中。

Ctrl+" 将值从活动单元格上方的单元格复制到单元格或编辑栏中。

Ctrl++ 显示用于插入空白单元格的“插入”对话框。

Ctrl+1 显示“单元格格式”对话框。

Ctrl+2 应用或取消加粗格式设置。

Ctrl+3 应用或取消倾斜格式设置。

Ctrl+4 应用或取消下划线。

Ctrl+5 应用或取消删除线。

Ctrl+6 在隐藏对象、显示对象和显示对象占位符之间切换。

Ctrl+7 显示或隐藏“常用”工具栏。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

V B A自定义菜单如何设置快捷键Static Sub AddMenu() '添加自定义菜单Dim NewMenuBar As CommandBarDim CX As CommandBarControl, JC As CommandBarControl, TB As CommandBarControl, SJ As CommandBarControl, BF As CommandBarControl Dim DY As CommandBarControl, BZ As CommandBarControl, XX As CommandBarControl, USE As CommandBarControl, WH As CommandBarControl Dim CW As CommandBarControl, TJ As CommandBarControl, LJC As CommandBarControl, YZ2 As CommandBarControl, YJC As CommandBarControl Dim LDQ As CommandBarControl, LNB As CommandBarControl, SDQ As CommandBarControl, SNB As CommandBarControl, LAll As CommandBarControl Dim JSB As CommandBarControl, SAll As CommandBarControl, DDQ As CommandBarControl, DNB As CommandBarControl, CDQ As CommandBarControl Dim CNB As CommandBarControl, C0 As CommandBarControl, CTZ As CommandBarControl, BF1 As CommandBarControl, BF2 As CommandBarControl Dim BF8 As CommandBarControl, DY1 As CommandBarControl, DY2 As CommandBarControl, SM As CommandBarControl, FG As CommandBarControl Dim KK As CommandBarControl, Bh1 As CommandBarControl, Bh2 As CommandBarControl, JB1 As CommandBarControl, JB2 As CommandBarControl Dim KB As CommandBarControl, FZ As CommandBarControl, SY As CommandBarControl, CZ As CommandBarControl, Z1 As CommandBarControl Dim Z2 As CommandBarControl, NH As CommandBarControl, B1 As CommandBarControl, B2 As CommandBarControl, B3 As CommandBarControl, BD As CommandBarControlDim B5 As CommandBarControl, B6 As CommandBarControl, S1 As CommandBarControl, S2 As CommandBarControl, S3 As CommandBarControl Dim S5 As CommandBarControl, S6 As CommandBarControl, D1 As CommandBarControl, D2 As CommandBarControl, D3 As CommandBarControl Dim D5 As CommandBarControl, D6 As CommandBarControl, C1 As CommandBarControl, C2 As CommandBarControl, C3 As CommandBarControl Dim C5 As CommandBarControl, C6 As CommandBarControl, TJF As CommandBarControl, TL As CommandBarControl, CL As CommandBarControl Dim ClCells As CommandBarControl, ShHL As CommandBarControlApplication.ScreenUpdating = FalseOn Error Resume NextMenuBars("MyMenuBar").Delete'定义菜单Set NewMenuBar = CommandBars.Add(MenuBar:=True) = "MyMenuBar"NewMenuBar.Visible = True'定义一级菜单项Set CX = NewMenuBar.Controls.Add(Type:=msoControlPopup) CX.Caption = "程序设置"CX.Visible = TrueSet JC = NewMenuBar.Controls.Add(Type:=msoControlPopup) JC.Caption = "基础数据"JC.Visible = TrueSet TB = NewMenuBar.Controls.Add(Type:=msoControlPopup) TB.Caption = "报表审录"TB.Visible = TrueSet SJ = NewMenuBar.Controls.Add(Type:=msoControlPopup) SJ.Caption = "数据处理"SJ.Visible = TrueSet BF = NewMenuBar.Controls.Add(Type:=msoControlPopup) BF.Caption = "报表备份"BF.Visible = TrueSet DY = NewMenuBar.Controls.Add(Type:=msoControlPopup) DY.Caption = "打印控制"DY.Visible = TrueSet BZ = NewMenuBar.Controls.Add(Type:=msoControlPopup) BZ.Caption = "帮助信息"BZ.Visible = True'定义二级菜单项Set XX = CX.Controls.Add(Type:=msoControlButton) With XX.Caption = "企业信息".OnAction = "ShowXX".FaceId = 1016End WithSet USE = CX.Controls.Add(Type:=msoControlButton) With USE.Caption = "操作设定".OnAction = "UserSet".FaceId = 1980End WithSet TIM = CX.Controls.Add(Type:=msoControlButton) With TIM.Caption = "报表时期".OnAction = "ChangeMonth".BeginGroup = True '菜单选项之间的分隔线End WithSet WH = CX.Controls.Add(Type:=msoControlPopup) With WH.Caption = "报表维护".BeginGroup = True '菜单选项之间的分隔线End WithSet CW = JC.Controls.Add(Type:=msoControlPopup) With CW.Caption = "财务报表"End WithSet TJ = JC.Controls.Add(Type:=msoControlPopup)With TJ.Caption = "统计数据"End WithSet LJC = JC.Controls.Add(Type:=msoControlButton) With LJC.Caption = "基础数据综合录入".BeginGroup = True '菜单选项之间的分隔线.OnAction = "ShowJC".FaceId = 353End WithSet YZ2 = JC.Controls.Add(Type:=msoControlButton) With YZ2.Caption = "增表二数据套用".BeginGroup = True '菜单选项之间的分隔线.OnAction = "CountZ1".FaceId = 211End WithSet YJC = JC.Controls.Add(Type:=msoControlButton) With YJC.Caption = "基础数据导入主表".BeginGroup = True '菜单选项之间的分隔线.OnAction = "CountJC".FaceId = 938End WithSet LDQ = TB.Controls.Add(Type:=msoControlPopup) With LDQ.Caption = "录入定期报表"End WithSet LNB = TB.Controls.Add(Type:=msoControlButton) With LNB.Caption = "录入年报报表".OnAction = "ShowNB" '无.FaceId = 162End WithSet SDQ = TB.Controls.Add(Type:=msoControlPopup) With SDQ.Caption = "定期报表审核".BeginGroup = True '菜单选项之间的分隔线End WithSet SNB = TB.Controls.Add(Type:=msoControlButton) With SNB.Caption = "年报报表审核".OnAction = "CheckNB".FaceId = 172End WithSet JSB = TB.Controls.Add(Type:=msoControlButton) With JSB.Caption = "表间数据计算".OnAction = "CountBB".FaceId = 283.BeginGroup = True '菜单选项之间的分隔线End WithSet LAll = TB.Controls.Add(Type:=msoControlButton) With LAll.Caption = "当期报表通录".BeginGroup = True '菜单选项之间的分隔线.OnAction = "ShowBB".FaceId = 212End WithSet SAll = TB.Controls.Add(Type:=msoControlButton) With SAll.Caption = "当期报表全审".OnAction = "CheckBB".FaceId = 790.BeginGroup = True '菜单选项之间的分隔线End WithSet DDQ = SJ.Controls.Add(Type:=msoControlPopup) With DDQ.Caption = "定期数据导入"End WithSet DNB = SJ.Controls.Add(Type:=msoControlButton) With DNB.Caption = "年报数据导入".OnAction = "InNB".FaceId = 237End WithSet CDQ = SJ.Controls.Add(Type:=msoControlPopup) With CDQ.Caption = "生成定期数据".BeginGroup = True '菜单选项之间的分隔线End WithSet CNB = SJ.Controls.Add(Type:=msoControlButton) With CNB.Caption = "生成年报报表数据".FaceId = 762.OnAction = "OutNB"End WithSet C0 = SJ.Controls.Add(Type:=msoControlButton) With C0.Caption = "生成全部数据".FaceId = 721.OnAction = "OutAll".BeginGroup = True '菜单选项之间的分隔线End WithSet CTZ = SJ.Controls.Add(Type:=msoControlButton) With CTZ.Caption = "生成统计台账".FaceId = 222.OnAction = "OutTZ"End WithSet BF1 = BF.Controls.Add(Type:=msoControlButton) With BF1.Caption = "备份定期报表".FaceId = 356.OnAction = "Copy1"End WithSet BF2 = BF.Controls.Add(Type:=msoControlButton) With BF2.Caption = "备份年报套表".FaceId = 1665.OnAction = "Copy2"End WithSet BF8 = BF.Controls.Add(Type:=msoControlButton) With BF8.Caption = "程序数据表转存".FaceId = 749.OnAction = "CopyAll".BeginGroup = True '菜单选项之间的分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet DY0 = DY.Controls.Add(Type:=msoControlButton) With DY0.Caption = "预览调整".FaceId = 25.OnAction = "Print0"End WithSet DY1 = DY.Controls.Add(Type:=msoControlButton) With DY1.Caption = "打印当前报表".FaceId = 4.OnAction = "Print1"End WithSet SM = BZ.Controls.Add(Type:=msoControlButton) With SM.Caption = "程序说明".FaceId = 984.OnAction = "Help"End WithSet FG = BZ.Controls.Add(Type:=msoControlPopup) With FG.Caption = "统计法规参考".BeginGroup = True '菜单选项之间的分隔线End WithSet BB = BZ.Controls.Add(Type:=msoControlButton) With BB.Caption = "程序版本信息".OnAction = "ShowKK".FaceId = 809.BeginGroup = True '菜单选项之间的分隔线End With'定义三级菜单项Set JB1 = WH.Controls.Add(Type:=msoControlButton) With JB1.Caption = "工作表解锁".FaceId = 916.OnAction = "JB1"End WithSet Bh1 = WH.Controls.Add(Type:=msoControlButton)With Bh1.Caption = "锁定工作表".FaceId = 894.OnAction = "Bh1"End WithSet JB2 = WH.Controls.Add(Type:=msoControlButton)With JB2.Caption = "工作簿解锁".FaceId = 719.OnAction = "JB2".BeginGroup = True '菜单选项之间的分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet Bh2 = WH.Controls.Add(Type:=msoControlButton)With Bh2.Caption = "锁定工作簿".FaceId = 718.OnAction = "Bh2"If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet DelCell = WH.Controls.Add(Type:=msoControlButton) With DelCell.Caption = "清除本月表内数据".FaceId = 20.OnAction = "Clear1".BeginGroup = True '分隔线End WithSet ClCells = WH.Controls.Add(Type:=msoControlButton) With ClCells.Caption = "清除本表所有数据".OnAction = "ClearAll"If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet SHL = WH.Controls.Add(Type:=msoControlButton) With SHL.Caption = "行列编辑信息".FaceId = 11.OnAction = "ShowRC".BeginGroup = True '分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet KB = WH.Controls.Add(Type:=msoControlButton)With KB.Caption = "查阅所有表".FaceId = 8.OnAction = "ShowAll".BeginGroup = True '分隔线If Man = 0 Then.Enabled = FalseEnd IfEnd WithSet FZ = CW.Controls.Add(Type:=msoControlButton) With FZ.Caption = "资产负债表".FaceId = 133.OnAction = "ShowFZ"End WithSet SY = CW.Controls.Add(Type:=msoControlButton) With SY.Caption = "损益(利润)表".FaceId = 136.OnAction = "ShowSY"End WithSet CZ = TJ.Controls.Add(Type:=msoControlButton) With CZ.Caption = "总产值计算表".FaceId = 17.OnAction = "ShowCZ".BeginGroup = True '分隔线End WithSet Z1 = TJ.Controls.Add(Type:=msoControlButton) With Z1.Caption = "增加值计算表一".FaceId = 144.OnAction = "ShowZ1"End WithSet Z2 = TJ.Controls.Add(Type:=msoControlButton) With Z2.Caption = "增加值计算表二".FaceId = 144.OnAction = "ShowZ2"End WithSet NH = TJ.Controls.Add(Type:=msoControlButton) With NH.Caption = "能耗记录表".FaceId = 107.OnAction = "ShowNH"End WithSet B1 = LDQ.Controls.Add(Type:=msoControlButton) With B1.Caption = "B201表".FaceId = 483.OnAction = "Show201"End WithSet B2 = LDQ.Controls.Add(Type:=msoControlButton) With B2.Caption = "B202表".FaceId = 481.OnAction = "Show202"End WithSet B3 = LDQ.Controls.Add(Type:=msoControlButton) With B3.Caption = "B203表".FaceId = 484.OnAction = "Show203".BeginGroup = True '分隔线End WithSet B5 = LDQ.Controls.Add(Type:=msoControlButton) With B5.Caption = "P205表".FaceId = 482.OnAction = "Show205"End WithSet B6 = LDQ.Controls.Add(Type:=msoControlButton) With B6.Caption = "P206表".FaceId = 59.OnAction = "Show206".BeginGroup = True '分隔线End WithSet BD = LDQ.Controls.Add(Type:=msoControlButton) With BD.Caption = "乡企定综1表".FaceId = 1763.OnAction = "ShowD1".BeginGroup = True '分隔线End WithSet S1 = SDQ.Controls.Add(Type:=msoControlButton) With S1.Caption = "B201表".FaceId = 329.OnAction = "Check201"End WithSet S2 = SDQ.Controls.Add(Type:=msoControlButton) With S2.Caption = "B202表".OnAction = "Check202"End WithSet S3 = SDQ.Controls.Add(Type:=msoControlButton) With S3.Caption = "B203表".FaceId = 107.OnAction = "Check203".BeginGroup = True '分隔线End WithSet S5 = SDQ.Controls.Add(Type:=msoControlButton) With S5.Caption = "P205表".OnAction = "Check205"End WithSet S6 = SDQ.Controls.Add(Type:=msoControlButton) With S6.Caption = "P206表".FaceId = 1715.OnAction = "Check206".BeginGroup = True '分隔线End WithSet D1 = DDQ.Controls.Add(Type:=msoControlButton) With D1.Caption = "B201表".FaceId = 239.OnAction = "In201".BeginGroup = True '分隔线End WithSet D2 = DDQ.Controls.Add(Type:=msoControlButton) With D2.Caption = "B202表".OnAction = "In202".BeginGroup = True '分隔线End WithSet D3 = DDQ.Controls.Add(Type:=msoControlButton) With D3.Caption = "P203表".FaceId = 317.OnAction = "In203".BeginGroup = True '分隔线End WithSet D5 = DDQ.Controls.Add(Type:=msoControlButton) With D5.Caption = "P205表".OnAction = "In205"End WithSet D6 = DDQ.Controls.Add(Type:=msoControlButton) With D6.Caption = "P206表".FaceId = 271.OnAction = "In206".BeginGroup = True '分隔线End WithSet C1 = CDQ.Controls.Add(Type:=msoControlButton) With C1.Caption = "B201表".FaceId = 538.OnAction = "Out201"End WithSet C2 = CDQ.Controls.Add(Type:=msoControlButton) With C2.Caption = "B202表".OnAction = "Out202"End WithSet C3 = CDQ.Controls.Add(Type:=msoControlButton) With C3.Caption = "B203表".FaceId = 439.OnAction = "Out203".BeginGroup = True '分隔线End WithSet C5 = CDQ.Controls.Add(Type:=msoControlButton) With C5.Caption = "P205表".OnAction = "Out205"End WithSet C6 = CDQ.Controls.Add(Type:=msoControlButton) With C6.Caption = "P206表".FaceId = 270.OnAction = "Out206".BeginGroup = True '分隔线End WithSet TJF = FG.Controls.Add(Type:=msoControlButton) With TJF.Caption = "统计法".FaceId = 463.OnAction = "ShowTJF"End WithSet TL = FG.Controls.Add(Type:=msoControlButton) With TL.Caption = "统计管理条例".FaceId = 942.OnAction = "ShowTL"End WithSet CL = FG.Controls.Add(Type:=msoControlButton) With CL.Caption = "自由裁量权".FaceId = 983.OnAction = "ShowCLQ"End WithApplication.MacroOptions Macro:="show201", HasShortcutKey:=True, ShortcutKey:="1"Application.ScreenUpdating = TrueEnd Sub。

相关文档
最新文档