Add text to "Author" field without replacing existing text

Keyboard macros or custom scripts

Add text to "Author" field without replacing existing text

Postby fracture62 » Tue Dec 01, 2020 1:21 pm

Hello,

so I am running a script that processes a document and sets certain text inside the author field, for that I use:

Code: Select all   Expand viewCollapse view
oDoc.getDocumentProperties().Author = cPrintText

however some documents have pre-existing text in the author field, and this will overwrite it.

How would I go about keeping the existing text in the field and just adding the wanted text to it?
Open Office 3.3 + Windows 10
fracture62
 
Posts: 1
Joined: Tue Dec 01, 2020 1:12 pm

Re: Add text to "Author" field without replacing existing te

Postby RoryOF » Tue Dec 01, 2020 1:34 pm

Have your code read the existing text, then append the new to it and write it back.
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32860
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Add text to "Author" field without replacing existing te

Postby JeJe » Tue Dec 01, 2020 2:29 pm

That's done with &

Assuming you want a space " " between old and new

Code: Select all   Expand viewCollapse view
oDoc.getDocumentProperties().Author =  oDoc.getDocumentProperties().Author & " " & cPrintText
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1601
Joined: Wed Mar 09, 2016 2:40 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests