Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
jezzica85 jezzica85 is offline
external usenet poster
 
Posts: 71
Default Paragraph alignment in a macro

Hi everybody,
I'm trying to write a macro, and one of the first steps I want is to delete
any text that is center-aligned. I tried to record a macro, using the find
and replace, but then when I ran the macro I couldn't make it work. I don't
know much about writing macro code, does anybody know how to put this into a
macro? I only need a little snippet of code, if you can.
Thanks!
jezzica85
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Paragraph alignment in a macro

Dim i As Long

With ActiveDocument
For i = .Paragraphs.Count To 1 Step -1
If .Paragraphs(i).Alignment = wdAlignParagraphCenter Then
.Paragraphs(i).Range.Delete
End If
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"jezzica85" wrote in message
...
Hi everybody,
I'm trying to write a macro, and one of the first steps I want is to
delete
any text that is center-aligned. I tried to record a macro, using the find
and replace, but then when I ran the macro I couldn't make it work. I
don't
know much about writing macro code, does anybody know how to put this into
a
macro? I only need a little snippet of code, if you can.
Thanks!
jezzica85



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default Paragraph alignment in a macro

Hi Jezzica,

Sub Test345()
Dim rDcm As Range
Dim rPrg As Paragraph
Set rDcm = ActiveDocument.Range
For Each rPrg In rDcm.Paragraphs
If rPrg.Alignment = wdAlignParagraphCenter Then
rPrg.Range.Delete
End If
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Prompt When opening merged documents Jeni Q Mailmerge 14 August 11th 05 09:10 PM
Macro Button Won't Stay on Toolbar caleb Microsoft Word Help 2 June 14th 05 11:59 PM
Paragraph alignment in table Word 2003 José Spanjaard Page Layout 7 May 31st 05 11:57 PM
Possible bug when recording a Word Macro Raven95 Microsoft Word Help 4 April 30th 05 09:49 PM
Page breaks in justifed text WWALKER Microsoft Word Help 7 March 17th 05 04:48 AM


All times are GMT +1. The time now is 04:08 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"