vba - Word style is changed after applying ApplyListTemplate -


i have word document containing numbered list this

  1. item 1
  2. item 2
  3. item 3

the list style "list paragraph". left indent of "list paragraph" 0.5". if run following code reapply style "list paragraph", left indent of style 0.75"

dim t listtemplate set t = activedocument.styles("list paragraph").listtemplate t.listlevels(1).resetonhigher = true selection.range.listformat.applylisttemplate t, false, wdlistapplytowholelist 

as result, list shifted right 0.25". i'm wondering why method applylisttemplate change left indent of style "list paragraph".

before , after applying code, description of style are

"indent: left:  0.5" hanging:  0.25", numbered + level: 1 + numbering style: 1, 2, 3, … + start at: 1 + alignment: left + aligned at:  0.75" + indent at:  1", style: quick style, priority: 35 based on: text"  "indent: left:  0.75" hanging:  0.25", outline numbered + level: 1 + numbering style: 1, 2, 3, … + start at: 1 + alignment: left + aligned at:  0.75" + indent at:  1", style: quick style, priority: 35 based on: text" 

i found same behavior in both office 2003 , 2010

i can't test exact code because run-time error 5941, says "the requested member of collection not exist."

that being said, word has tendency (for me anyway) "fix" indent of list whenever change made formatting. there's setting tell word stop "fixing" lists, suggest adding following end of code:

with selection.paragraphformat     .leftindent = inchestopoints(0.75)          ' left indent     .rightindent = inchestopoints(0)            ' right indent     .firstlineindent = inchestopoints(-0.25)    ' first line indent end 

that give left indent of 0.5" , and hanging indent of 0.25" (even though numbers may little odd). don't need middle line starts .rightindent =, thought i'd include in event you'd want change well.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -