マクロを削除する 
テンプレートに入れたマクロを新規作成時に動作させたあとで削除したいときには次のようにすると消すことができます。
以下の例は新規作成の OnNew イベントにマクロが割り当てられているテンプレートのイベントを削除、ライブラリごとマクロを削除します。
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| | Sub NewFileCreated
UnRegisterEvent(oDoc, "OnNew")
RemoveLibrary(oDoc, "Standard")
End Sub
Sub UnRegisterEvent(oDoc As Object, sEventName As String )
oEvents = oDoc.getEvents()
If oEvents.hasByName(sEventName) Then
Dim aArgs(0) As New com.sun.star.beans.PropertyValue
oEvents.replaceByName(sEventName, aArgs)
End If
End Sub
Sub RemoveLibrary(oDoc As Object, sLibName As String)
oLibs = oDoc.BasicLibraries
If oLibs.hasByName(sLibName) Then
oLibs.removeLibrary(sLibName)
End If
End Sub
|