Find & replace in Text Box

I need to add quite some code snippets into a writer document. As I want to give those a constant background color I was thinking to use text boxes for this.

I’ll have to adjust timestamps in those code snippets though and can not manage to operate find & replace (ctrl +h) inside a text box. Is there a way to do that?

Ideally, you would use a paragraph style for Code. You can set a background color for the paragraph style as well as font, etc.

If you wanted the code to lie outside the main body of the work you could use frames rather than text boxes. Insert - Frame and you have a choice of interactively or by dialogue box.

Cheers, Al


In addition to @EarnestAl ,
If you want to use code snippets within a paragraph, you can use a character style instead.

I assume that you basically work with styles and do not format directly. This could lead to unwanted results if you use direct formatting and style sheets at the same time.

Professional text composition with Writer


It is possible with macro, but it is not so easy :-(.

Sub TextBoxes
	dim oDoc as object, oDrawpage as object, o as object, i&
	for i=0 to oDrawpage.Count-1
		if o.supportsService("") then
			'xray o 'actual Text Box
			msgbox o.String
		end if
End Sub

For string in TextBox you can use classical commands Left/Right/Mid or createTextCursor() or Text Search

1 Like

no macros for me! thx anyway for sharing that wisdom.

1 Like