so, i've got this doc that has a bunch of comments in the righthand sidebar with dotted-lines connecting them to the main text. but it's all incredibly confusing to me. i don't know what goes with what. it'd be much easier if the comments were placed right in the text where appropriate, maybe in a different color, if necessary.
is that possible? i'm working on something that has to be done in a hurry and i'm afraid i don't have time to learn a whole new way of doing things. perhaps later, but not now.
what do you think?
[Solved] Can I merge sidebar comments into main text?
[Solved] Can I merge sidebar comments into main text?
Last edited by Hagar Delest on Thu May 21, 2020 8:36 pm, edited 1 time in total.
Reason: tagged solved
Reason: tagged solved
OOo 2.3.X on MS Windows Vista
Re: can i merge sidebar comments into main text?
You can create a character style with a background color for this.
The following macro will create a character style called "CommentStyle" with a yellow background, and copy the text of the comments into the document in that style.
TO BE SAFE MAKE A COPY OF YOUR DOCUMENT FIRST BEFORE RUNNING.
The following macro will create a character style called "CommentStyle" with a yellow background, and copy the text of the comments into the document in that style.
TO BE SAFE MAKE A COPY OF YOUR DOCUMENT FIRST BEFORE RUNNING.
Code: Select all
cs = thiscomponent.stylefamilies.getbyname("CharacterStyles")
ss=thiscomponent.createinstance("com.sun.star.style.CharacterStyle")
ss.charbackcolor = rgb(255,255,20)
cs.insertbyname("CommentStyle",ss)
en =thiscomponent.textfields.createenumeration
tc = thiscomponent.text.createtextcursorbyrange(thiscomponent.text.start)
do until en.hasmoreelements = false
ff= en.nextelement
anch= ff.anchor
tc.gotorange(anch.end,false)
tc.string =ff.textrange.text.string
tc.charstylename = "CommentStyle"
loop
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: can i merge sidebar comments into main text?
thank you for that. it'll merge the comments into the text, right?
now all i have to do is figure out macros!
now all i have to do is figure out macros!
OOo 2.3.X on MS Windows Vista
Re: can i merge sidebar comments into main text?
You have an ancient version of OO according to your signature. All I can do is go through what to do on my more up to date version as I don't have that old version. It may or may not be the same
Make a copy of your document, close all your others and open that.
Go to Tools menu/Macros/Organise Macros/Openoffice basic
In the dialog that pops up select the name of your document from the left side listbox and click the "New" button.
A popup box will ask you for the name of a module - just click on Okay.
You'll be taken to the macro area for your document where you'll find this:
When that's done press F5 to run the macro and see if the result is what you want.
Make a copy of your document, close all your others and open that.
Go to Tools menu/Macros/Organise Macros/Openoffice basic
In the dialog that pops up select the name of your document from the left side listbox and click the "New" button.
A popup box will ask you for the name of a module - just click on Okay.
You'll be taken to the macro area for your document where you'll find this:
Copy and past the macro code I wrote above in between the sub main and end sub so it looks like this
REM ***** BASIC *****
Sub Main
End Sub
Code: Select all
REM ***** BASIC *****
Sub Main
cs = thiscomponent.stylefamilies.getbyname("CharacterStyles")
ss=thiscomponent.createinstance("com.sun.star.style.CharacterStyle")
ss.charbackcolor = rgb(255,255,20)
cs.insertbyname("CommentStyle",ss)
en =thiscomponent.textfields.createenumeration
tc = thiscomponent.text.createtextcursorbyrange(thiscomponent.text.start)
do until en.hasmoreelements = false
ff= en.nextelement
anch= ff.anchor
tc.gotorange(anch.end,false)
tc.string =ff.textrange.text.string
tc.charstylename = "CommentStyle"
loop
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Can I merge sidebar comments into main text?
Slightly improved version makes sure the textfields are all comments in case you have other ones in the document:
Code: Select all
cs = thiscomponent.stylefamilies.getbyname("CharacterStyles")
if cs.hasbyname("CommentStyle") = false then
ss=thiscomponent.createinstance("com.sun.star.style.CharacterStyle")
ss.charbackcolor = rgb(255,255,20)
cs.insertbyname("CommentStyle",ss)
end if
en =thiscomponent.textfields.createenumeration
tc = thiscomponent.text.createtextcursorbyrange(thiscomponent.text.start)
do until en.hasmoreelements = false
ff= en.nextelement
if ff.supportsService("com.sun.star.text.TextField.Annotation") then
anch= ff.anchor
tc.gotorange(anch.end,false)
tc.string =ff.textrange.text.string
tc.charstylename = "CommentStyle"
end if
loop
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Can I merge sidebar comments into main text?
good golly that worked perfectly. what a life saver. i can't thank you enough. thank you!!!!
OOo 2.3.X on MS Windows Vista
Re: Can I merge sidebar comments into main text?
If you want to change the color or hide/show them you just have to change the properties of the character style.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)