andreas
Mon Mar 03 03:27:41 PST 2008
On 2 Mrz., 23:08, "Greg Maxey" <gma...@mvps.oSCARrOMEOgOLF> wrote:
> Andreas,
>
> You might have to change or add to the Cases of "Heading" styles but this
> might work.
>
> Sub ScratchMacro()
> Dim oPar As Word.Paragraph
> Dim oRng As Word.Range
> For Each oPar In ActiveDocument.Paragraphs
> =A0 Select Case oPar.Style
> =A0 =A0 Case "Heading 1", "Heading 2"
> =A0 =A0 =A0 Set oRng =3D oPar.Range
> =A0 =A0 =A0 With oRng.Find
> =A0 =A0 =A0 =A0 .Text =3D "(^t)( )@([! ])"
> =A0 =A0 =A0 =A0 .Replacement.Text =3D "\1\3"
> =A0 =A0 =A0 =A0 .MatchWildcards =3D True
> =A0 =A0 =A0 =A0 .Execute Replace:=3DwdReplaceOne
> =A0 =A0 =A0 End With
> =A0 =A0 Case Else
> =A0 =A0 =A0 'Do nothing
> =A0 End Select
> Next oPar
> End Sub
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Greg Maxey - =A0Word MVP
>
> My web site
http://gregmaxey.mvps.org
> Word MVP web site
http://word.mvps.org
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> "andreas" <andreas.her...@gmx.de> wrote in message
>
> news:316cbe83-fed6-48b3-a5e6-00219fc76890@h11g2000prf.googlegroups.com...
>
>
>
> > Dear Experts,
> > I got a long word-file where the user has inserted spaces (1 to n)
> > after the tab of the built-in heading styles (featuring hanging
> > indents) and before the text of the headings. Example
>
> > 1.1Tab(HangingIndent)RedundantLeadingSpacesHeadingText
>
> > But it should be:
> > 1.1Tab(HangingIndent)HeadingText
>
> > So how can I programmatically (VBA) drop these redundant leading
> > spaces?
>
> > Help is much appreciated. Thank you very much in advance.
>
> > Regards, Andreas- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
Dear Greg,
thanks for the quick answer. Although I altered it slightly as you
suggested to include my specific heading style, it regrettably did not
work. As I stated below in response to Doug's suggestion, I guess the
tabs of the built-in heading styles cannot be accessed the way you
suggest. I hope I could make myself clear. Thank you for your help.
Regards, Andreas