Return-Path: X-Original-To: apmail-incubator-ooo-users-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47EE9CE86 for ; Tue, 17 Jul 2012 11:12:40 +0000 (UTC) Received: (qmail 43062 invoked by uid 500); 17 Jul 2012 11:12:39 -0000 Delivered-To: apmail-incubator-ooo-users-archive@incubator.apache.org Received: (qmail 42974 invoked by uid 500); 17 Jul 2012 11:12:38 -0000 Mailing-List: contact ooo-users-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-users@incubator.apache.org Delivered-To: mailing list ooo-users@incubator.apache.org Received: (qmail 42902 invoked by uid 99); 17 Jul 2012 11:12:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 11:12:37 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gurus.knugum@gmail.com designates 209.85.220.175 as permitted sender) Received: from [209.85.220.175] (HELO mail-vc0-f175.google.com) (209.85.220.175) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 11:12:30 +0000 Received: by vcbfy27 with SMTP id fy27so160824vcb.6 for ; Tue, 17 Jul 2012 04:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=X3PIrXJ6Gv/JsEUjvsf8d2SK/EqPJ5wh6aVpC/UlvY8=; b=e+/bkbJHdgzesqZocK3yEbYG/H8xU5X433cphOKtT7VAczBoxrs74luKFzs0fl3C6V 2zSg6iJogYvXBwUFPrR1DyUa7ItUGF4aENiaRfs7sUrEWRDSp0ZmgaUjPVcNAQ91rf6a HkpqZ2VN04iNK8UQX6cGtbyR1HaIQc10U+AmIJXPczJVKc0kvehA2m89qliJLBkhd0J9 +N2ALxuxCDtydUl/w0Rqb+LGGLAzhiT/0CzOZw0S/QuJha6p7C1wZzD+Q/cdFnHO8H8Y isY8bowreKEO0pRJ+7UDcq0mcjz6XTroQWir7uzIymrtnfKnBpVY+AD1z94mHoMLUl+u bihg== MIME-Version: 1.0 Received: by 10.220.141.203 with SMTP id n11mr894153vcu.74.1342523529701; Tue, 17 Jul 2012 04:12:09 -0700 (PDT) Received: by 10.220.196.86 with HTTP; Tue, 17 Jul 2012 04:12:09 -0700 (PDT) In-Reply-To: References: <5004C8DF.5030208@casaerwin.org> <991381645030483ABDAF4FF028EB6F89@SAI> Date: Tue, 17 Jul 2012 13:12:09 +0200 Message-ID: Subject: Re: Macro or its equivalent to replace double spaces with single space. From: Johnny Rosenberg To: ooo-users@incubator.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 2012/7/17 Johnny Rosenberg : > 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 use= d >> 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 =E2=80=9DUseful Macro Inform= ation > For OpenOffice.org By Andrew Pitonyak=E2=80=9D, which is a PDF that you c= an > download somewhere: > > REM ***** BASIC ***** > > Sub RemoveRedundantSpaces > Dim oReplace as object > oReplace =3D ThisComponent.createReplaceDescriptor() > > With oReplace > .SearchString =3D " " > .ReplaceString =3D " " > End With > > While ThisComponent.ReplaceAll(oReplace)>0 > Wend > End Sub I made some changes to the macro, which now will tell you how many spaces were removed: REM ***** BASIC ***** Option Explicit Sub RemoveRedundantSpaces Dim oReplace as object oReplace =3D ThisComponent.createReplaceDescriptor() With oReplace .SearchString =3D " " .ReplaceString =3D " " End With Dim Count As Integer, TotalCount As Integer Do Count=3DThisComponent.ReplaceAll(oReplace) TotalCount=3DTotalCount+Count Loop While Count>0 =09 Select Case TotalCount Case 0 Print "No redundant spaces found." Case 1 Print "1 space was removed." Case Else Print TotalCount & " spaces were removed." End Select End Sub > > > This macro also takes care of tripple spaces and=E2=80=A6 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=E2=80=A6 > > Much better than using the crappy macro recorder anyway. And shorter=E2= =80=A6 > > If you write the documents yourself, there is a simple way to prevent > double spaces in the first place, something like: > Tools =E2=86=92 Options for auto correction=E2=80=A6 =E2=86=92 Click the = Options tab =E2=86=92 =E2=98=92 > 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 > =E3=82=B8=E3=83=A7=E3=83=8B=E3=83=BC=E3=83=BB=E3=83=AD=E3=83=BC=E3=82=BC= =E3=83=B3=E3=83=90=E3=83=BC=E3=82=B0 --------------------------------------------------------------------- To unsubscribe, e-mail: ooo-users-unsubscribe@incubator.apache.org For additional commands, e-mail: ooo-users-help@incubator.apache.org