Changing the author name in comments

I’ve done a search here and found nothing relevant. Basically, I’ve gone and marked a whole bunch of uni assignments while logged in as my wife. I’ve logged in as myself now and have author details set in User Data. One thread I found suggested I reset the document properties in File → Properties → General but that does nothing. So, my needs are simple - how do I change my wife’s name into mine and have that reflected in the comments I’ve made in essays?

Thanks in advance!

The “identity” is stored in Tools>Options, LO>User Data. You must change this data before commenting and saving.

Since it is really boring to modify those settings every time you edit a document, create several user accounts on your machine. Each account will have its own LO user profile which you can configure for a “permanent” identity.

Configure document or directory access rights so that the documents can be shared (read and write) between the accounts. You can also create a common “group” with read/write access and include both your account and your wife’s inside the group.

1 Like

Or start Libreoffice specifying the folder for user settings, for example (MS Windows):

swriter.exe -env:UserInstallation=file:///c:/Temp/LibreOffice

The first time you call it, the necessary infrastructure will be created in the folder specified by the parameter. You can make the necessary settings in LibreOffice, which will be saved in the specified folder. These settings will be used in subsequent calls.

If I understand what you are looking for, you want to change the listed author on already existing comments, correct?
If so, here is Macro that should do what you need. But take note, it currently will change ALL comments to have the same Author, it can, however, be made to only change the ones made “by your wife”.
You will be running this macro in the Document you want the comment author changed in.
Before running it, change the sAuthor value to your name (Or what name you want to appear).
To make the changes appear, you will have to re-open the document, or uncomment the indicated line in the Macro, which will re-insert each comment, but retain the date/placement.
Maybe test this on a copy of the document to make sure it does what you want first.

Option Explicit
Sub ReAuthorComments

Dim oTextFields, oTextField
Dim sAuthor

sAuthor = "Name" ' Change this.

	oTextFields = ThisComponent.getTextFields.createEnumeration()
	If Not IsObject(oTextFields) Then 
		MsgBox "No Fields found."
		Exit Sub
	EndIf

REM Cycle through all fields
	While oTextFields.hasMoreElements()
		oTextField = oTextFields.nextElement()

			REM If TextField is a Comment, check the Author and modify as necessary.
			If oTextField.supportsService("com.sun.star.text.TextField.Annotation") Then
				If oTextField.Author() <> sAuthor Then 
					oTextField.Author = sAuthor
					REM Uncomment this next line if you want the comments to be visually updated instantly.
					REM Otherwise re-open the document after running the Macro.
					' ThisComponent.Text.createTextCursorByRange(oTextField.Anchor()).Text.insertTextContent(oTextField.Anchor(), oTextField, True)
				EndIf
			EndIf
	WEnd
	MsgBox "Comments updated successfully."
End Sub

Thank you! Exactly what I was after. I was all ready to run a sed or something through the document xmls to change them, but this works without me having to pull the .odt apart. Thank you again.

1 Like

You are most welcome, glad it was what you needed.