|
Excel是我们日常工作和学习必不缺少的软件之一,由于每天跟它打交道,很多朋友就想自己写一些VBA程序来简单开发excel,如何将自己写的VBA发给别人用,或者将程序嵌入excel的菜单中,无论打开哪个excel都可以用呢?

工具/原料
电脑一台office软件方法/步骤
首先需要打开VBA编辑器,有三种方法:
第一种:快捷键,Alt+F11
第二种:右键工作簿标签,选择“查看代码”
第三种:点击菜单栏的开发工具,选择Visual Basic选项卡


编辑代码,我只写了一个简单的功能:弹出“HelloWorld”对话框

将该Excel保存为加载宏xlam格式,千万不能选错了格式,否则无法加载excel中的宏代码

加载刚才保存的HelloWrold.xlam。点击文件-选项-加载项,然后点击转到。如图所示


把宏文件嵌入excel菜单。点击文件-选项-自定义功能区,在自定义功能区新建选项卡,再新建组,将左侧显示的宏命令添加至新建组内,新建的选项卡和组可以重命名,宏命令可以设置自己的图标


点击命令,如图所示
