PDA

View Full Version : Solved: modifying recorded code for lists



eed
02-16-2006, 12:58 PM
Hi, all,

I used the Macro recorder to get some code that would generate an outline-style numbered list. I'm still new to mangling VBA in Word, but I know that the recorder often produces excess "stuff." What I don't know is how far I can go in deleting stuff. What's the bare minimum of the Macro Recorder code that is needed to produce a correctly functioning numbered list? (I'm not pasting the code since it's verrry long and can be replicated by recording the creation of an outline numbered list.)

I appreciate any comments. I hope this will help me improve my ability to recognize which recorded statements are necessary and which are superfluous. http://vbaexpress.com/forum/images/smilies/053.gif

Thanks!!
~ eed

geekgirlau
02-16-2006, 04:48 PM
I recorded a quick macro to test, and noted that the recorder gives you code for all 9 levels! I think you can pretty much delete the following:

Any level lower than your numbering goes (eg if you are only using levels 1 and 2, delete all code relating to levels 3 to 9);
If you are not changing the font for the number, remove everything from With .Font to End With (repeat this for all the levels you need);
If it's not linked to a style, get rid of .LinkedStyle = "";
I would think that it's safe to get rid of the following, but I would comment these out rather than deleting them just in case:

.NumberStyle = wdListNumberStyleArabic;
.NumberPosition = CentimetersToPoints(0);
.Alignment = wdListLevelAlignLeft
.StartAt = 1

eed
02-21-2006, 07:46 AM
Thanks, geekgirlau! I had assumed that your first two bullet points would be true, but it helps to get confirmation. The lines you list in your last bullet point were the ones I was most uncertain about.

Thanks for helping me trim my code!

~ eed