Thursday 15 April 2010

Word-Scripting: replace nonbreaking spaces with thin spaces? -



Word-Scripting: replace nonbreaking spaces with thin spaces? -

i utilize word open (special) html documents printing , want write script prepare little issue:

in html file have numbers '15 cm' written '15 cm', there no line break between number '15' , unit 'cm'.

my problem is: spacing wide, when word expands spaces fit sentence margins.

so i'd replace these   kind of lean spaces using word vba script. guess need enumerate paragraphs, i'm not sure how replace text in there. came far, don't know how write html nbsp in word , utilize lean spaces, maybe can help me here?

sub makethinspaces() dim para paragraph each para in activedocument.paragraphs replace     here? next end sub

thin space unicode 8201. (a narrow no-break space 8239). should work code using selection object. ^s wildcard protected space, utilize chr(160)

selection.wholestory selection.find .text = "^s" .replacement.text = chrw(8201) .matchwildcards = true end selection.find.execute replace:=wdreplaceall

ms-word word-vba

No comments:

Post a Comment