Ask Your Question
0

Macro to move cursor from comments box to text.

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

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 close merge delete

2 Answers

Sort by » oldest newest most voted
0

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

pierre-yves samyn gravatar image

Hi

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("com.sun.star.text.textfield.Annotation")

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

oComment.attach(oCursor.start)

End Sub

Regards

edit flag offensive delete link more
0

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

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
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 80 times

Last updated: Jun 25 '17