PDA

View Full Version : Issue with macro to indent list paragraphs - please help finish code



JRobinson22
01-21-2013, 11:12 AM
Hi - I'm trying to develop a simple macro for moving bulleted lists over one indent. When I run the following code I'm getting this error message: Compile Error: Next without For'

Can anyone help me troubleshoot? thanks!


Sub bulletindent()
Dim LP As ListParagraphs
For Each LP In ActiveDocument.ListParagraphs
With LP
ListParagraphs.Indent

Next LP
End If
End Sub

gmaxey
01-21-2013, 01:26 PM
First LP is declared incorrectly. One LP can hardly be a collection of ListParagrapghs.

Secondly you have With statement that you don't need and even if you did, you don't have a corresponding End With Statement.

Thirdly, you have and End If statement that you don't need and even if you did you don't have a corresponding If statement.

Fourthly, ListParagraphs.Indent is meaningless:

Sub bulletindent()
Dim LP As Paragraph
For Each LP In ActiveDocument.ListParagraphs
LP.Indent
Next LP
End Sub

JRobinson22
01-21-2013, 04:26 PM
Thanks again Greg! As I'm sure you can tell, I'm not a coder. Your expert advice saved me A LOT of time! If you ever need a reference / testimonial on your web-site or anything like that, I'd be happy to help you out.

J