Ask Your Question

Macro to move cursor from comments box to text. [closed]

asked 2017-06-24 16:29:53 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi. I wish to create a macro that inserts the same text in a comment box each time but which then returns me back to the text again afterwards.

I was able to do it in Word by creating two macros, the first to insert the text box and then the second to take me from the text box back to the text again. I can't work out how to create the second macro though.

I know enough about macros to be able to do this, but anything more is at this point in time a bunch of gobbledegook. Can anyone help me?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-09 14:32:04.900503

2 Answers

Sort by » oldest newest most voted

answered 2017-06-24 17:46:45 +0200

pierre-yves samyn gravatar image


The macro below inserts the comment at the current position of the cursor. The cursor remains positioned in the text so there is no need to "go back" to the text. You just have to adapt name & text of comment.

Sub LibOInsertComment

dim oCursor as object
dim oComment as object

oCursor = ThisComponent.CurrentController.getViewCursor()
oComment = thiscomponent.createInstance("")

with oComment
    .Author = "Name Author Comment"
    .Content = "Text of comment"
    .DateTimeValue = CDateToUnoDateTime(now)
end with


End Sub


edit flag offensive delete link more

answered 2017-06-25 03:54:16 +0200

sue_s gravatar image

Pierre-Yves, you are, quite simply, a legend.

Thank you so much. I really appreciate it. It will make my days a whole lot easier!

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-06-24 16:29:53 +0200

Seen: 194 times

Last updated: Jun 25 '17