Remove all indenting? (Modifying recorded keystrokes so this actually works.)

S

StargateFan

Recording keystrokes is great for those of us who can never seem to
wrap our brains around vb <g>. I recorded this yesterday because I
ran into a RTF doct. that happened to be formatted with first-line
indenting. Didn't realize it until after running a text clean-up
macro and saw the indenting so added this in below to the cleanup
macro and it didn't work for the entire doct. Some of the first-line
indenting got left in.

Here's what I was left with after I trimmed out what I thought was not
needed from the recorded keys:

*********************************************************************************
Sub INDENTS_remove()
'
With Selection.ParagraphFormat
.Alignment = wdAlignParagraphLeft
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceAfter = 0
.LineSpacingRule = wdLineSpaceSingle
.FirstLineIndent = InchesToPoints(0)
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End Sub
*********************************************************************************

Since it leaves the odd one in, I know this isn't either complete or
completely right.

What's weird is that when I did the process again and recorded the
keystrokes once again, the new macro was virtually identical yet the
entire document was fixed. So I'm obviously missing something
somewhere.

Pls bear with me, I'm not very good at vb no matter how much I battle
with it. And the archives do mention how bad and incomplete recorded
keystrokes can be, it's just one has to start with something, eh?

Cheers. :eek:D
 
R

Russ

Recorded macros usually act on the Selection object, which means that you
need to select what you want changed. But you can amend the recorded macros
to act on other objects and their ranges.
Change:
With Selection.ParagraphFormat

To:
With ActiveDocument.Range.ParagraphFormat
To act on the whole document and not just on the selection.

Or:
With ActiveDocument.Paragraphs(2).Range.ParagraphFormat
To act on the second paragraph in the document only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How can we remove page formatting? 1
TOC problem 0
TOC Help 0
TOC Problem 0
A macro to increase line spacing 1
set hanging indent for second TOC 1
Table of Content 1
TOC Question 3

Top