Indenting paragraphs: better way of doing it?

T

TT

Hi,

I need to indent specific paragrahps (which I paste from Excel to Word). I
have been doing it as shown below: This paragraph in the example starts to
indent at line 10 and the indented paragraph is the third paragraph in the
text. I left out other parts of the code, I think the idea can be
understood.

Now, I'd like to know if there's a way of indenting the third paragraph in
the text without having to count the lines up until the line at which the
third paragraph begins, that is the tenth line in the example.

Hope you understand, a bit difficult to explain...

Thanks,
TT

----------------

Dim AppWD As Word.Application
Dim DocWD As Word.Document
Dim RangeWD As Word.Range
'Dim ParWD As Word.Paragraph

Set AppWD = CreateObject("Word.Application.11")
AppWD.Visible = True

Set DocWD = AppWD.Documents.Add
With DocWD
Set RangeWD = .Range
Sheets("T").Select
Range("A3").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 11
.Font.Bold = False
.PasteAndFormat Type:=wdFormatPlainText
.InsertAfter vbCr
.Start = .End + 1
.Collapse wdCollapseEnd
AppWD.Selection.MoveDown Unit:=wdLine, Count:=10
With AppWD.Selection.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = CentimetersToPoints(4.76)
.LeftIndent = CentimetersToPoints(4.76)
.FirstLineIndent = CentimetersToPoints(0)
End With
 
B

Birgit

Hi TT!

Would the following be what you are looking for?

Delete this line
AppWD.Selection.MoveDown Unit:=wdLine, Count:=10

Instead of this line
With AppWD.Selection.ParagraphFormat

use the following:

With AppWd.Paragraphs(3)

continue as you did
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = CentimetersToPoints(4.76)
.LeftIndent = CentimetersToPoints(4.76)
.FirstLineIndent = CentimetersToPoints(0)
End With

HTH, Birgit
 
T

TT

Thanks for helping, but that gives an error message "data member not found"
or something like that.

That's probably due to the fact that I'm controlling Word from Excel. (?)

TT
 

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

Top