OpenOffice.org Basic code snippet: Insert annotation

The following macro inserts a note into the currently opened document. I don’t know what to do with it just yet, but I’m sure this can come in handy at some point.

Sub Example_InsertAnnotation
  oDoc = ThisComponent
  oTextCursor = oDoc.Text.createTextCursor
  oTextCursor.goToEnd(False)
 
  Dim oDate As New com.sun.star.util.Date
  With oDate
    .Day = Day(Now)
    .Month = Month(Now)
    .Year = Year(Now)
  End With
 
  oTextAnnotation = oDoc.createInstance("com.sun.star.text.TextField.Annotation")
  With oTextAnnotation
    .Content = "Paolo was here!!"
    .Author = "PM"
    .Date = oDate
  End With
 
  oDoc.Text.insertTextContent( oTextCursor, oTextAnnotation, True) 	
 
End Sub

I found the code somewhere on the interweb, but I can’t remember where.

 
blog/ooobasicannotate.txt · Last modified: 2008/06/27 11:31 by dmpop
 
OpenOffice.org user? Read the Writer for Writers and Advanced Users book
GNU FDL OpenOffice.org Powered by DokuWiki