openoffice 在当前光标位置插入批注的宏
REM ***** BASIC *****
sub Main
oDoc = ThisComponent
Dim vDoc, vViewCursor, oCurs, vTextField
Dim s$
'Lets lie and say that this was added ten days ago!
Dim aDate As New com.sun.star.util.Date
With aDate
.Day = Day(Now - 10)
.Month = Month(Now - 10)
.Year = Year(Now - 10)
End With
vDoc = ThisComponent
vViewCursor = vDoc.getCurrentController().getViewCursor()
oCurs=vDoc.getText().createTextCursorByRange(vViewCursor.getStart())
s = "com.sun.star.text.TextField.Annotation"
vTextField = vDoc.createInstance(s)
With vTextField
.Author = "cai"
.Content = "hello 老板 cai"
'Ommit the date and it defaults to today!
.Date = aDate
End With
vDoc.Text.insertTextContent(oCurs, vTextField, False)
end sub