incubator-ooo-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johnny Rosenberg <>
Subject Re: Macro or its equivalent to replace double spaces with single space.
Date Tue, 17 Jul 2012 10:47:01 GMT
2012/7/17 Srinivasulu Bhattaram <>:
> I am new to Open Office.
> InWORD 2003 (and also in WORD 2007),
> I have craeted macros to remove double spaces with single spaces and used
> them extensively..
> How to have an equivalent of it in Open Office writer?
> I do not want to go through   Find    Replace.... kind of thing.
> seena

What about letting a macro do the search and replace for you?

I just wrote this one, with inspiration from ”Useful Macro Information
For By Andrew Pitonyak”, which is a PDF that you can
download somewhere:

REM  *****  BASIC  *****

Sub RemoveRedundantSpaces
	Dim oReplace as object
	oReplace = ThisComponent.createReplaceDescriptor()

	With oReplace
		.SearchString = "  "
		.ReplaceString = " "
	End With

	While ThisComponent.ReplaceAll(oReplace)>0
End Sub

This macro also takes care of tripple spaces and… well, it just
removes all spaces until there are only single spaces left. And it is
fast. Really fast.
I tested it myself, and it worked in all my test cases. Well, I didn't
test it THAT thoroughly, but still…

Much better than using the crappy macro recorder anyway. And shorter…

If you write the documents yourself, there is a simple way to prevent
double spaces in the first place, something like:
Tools → Options for auto correction… → Click the Options tab → ☒
Ignore double spaces

You can still make double spaces if you really want to, but it's less
likely to happen accidently.

Kind regards

Johnny Rosenberg

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message