1.使用word插件可以方便的开发一些word自定义功能。具体步骤如下: 首先新建一个DLL工程,引入Office插件开发库MSADDADR.dll,继承并实现接口就可以了。
Implements IDTExtensibility2
Private WithEvents cb As Office.CommandBarsPrivate Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
这个方法在dll插件更新的时候会调用
End Sub
Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
这个方法在关闭word程序的时候调用
End Sub
Private Sub
IDTExtensibility2_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
这个方法在打开word应用程序的时候调用具体的可以做一个初始化的工作 End Sub
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
这个方法在开始关闭word应用程序的时候调用
MsgBox "word discon"
End Sub
Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
MsgBox "word start" 这个方法在完全打开word后调用,在OnConnection End Sub Private Sub wordapp_OnUpdate()
End Sub
写完自己的东西后生成dll文件,然后进行注册,如下:
windows Registry Editor Version 5.00
[HKEY_CURRENT_USER/Software/Microsoft/Office/WOrd/Addins/WordCom.com]
"FriendlyName"="测试"
"Description"="word插件测试"
"LoadBehavior"=dword:00000003
"CommandLineSafe"=dword:00000001
其中WordCom.com中WordCom是工程名,com是类名.将上面注册代码运行。运行word就可以看到自己写的效果了.