编写VB AddIn工程

来源:互联网 发布:万网 域名维护费用 编辑:程序博客网 时间:2024/05/01 12:18

新建AddIn工程


在connect.dsr模块中有一行
    Set mcbMenuCommandBar = AddToAddInCommandBar("My AddIn")
定义了addin出现在菜单中的位置

设置Application为VisualBasic,做VB的AddIn


在frmaddin.frm模块中设计窗体并定义操作
模块使用了全局对象VBInstance
    Public VBInstance As VBIDE.VBE


VBIDE的简要模型如下

VBIDE:
  VBE:VBInstance
    VBProjects
      VBProject
        VBComponents
          VBComponent
            CodeMudule
              CodePane
            Designer
              VBControls
                VBControl
                  Properties
                    Propertie
                      name
                      value

 

显示一个代码窗口
VBInstance.VBProjects.Item(1).VBComponents(1).CodeModule.CodePane.Show

获得窗体上一部件的属性
Dim f As VBForm
Set f = VBInstance.VBProjects.Item(1).VBComponents(1).Designer
Debug.Print f.VBControls.Item(1).Properties.Item(1).Value

 

生成dll文件,并注册。

原创粉丝点击