alexpgp: (St. Jerome w/ computer)
[personal profile] alexpgp
As it turns out, I have a client who really, really does not like to see justified text in the documents I send him. This used to eat a certain amount of time during the post-translation phase, as the folks who put together the source document mix justified willy-nilly with left-aligned, with centered, as well as a dash of right-alignment to round things off.

So it was only natural for me to want to write a Word macro that, basically, goes through each paragraph within a document and changes only those with justified text to display as left-aligned. Check it out:
Sub ChangeJustifiedToLeft()

Dim oSource As Document
Set oSource = ActiveDocument

j = oSource.Paragraphs.Count

For i = 1 To j
StatusBar = "Processing " & i & " of " & j
If oSource.Paragraphs(i).Format.Alignment = wdAlignParagraphJustify Then
oSource.Paragraphs(i).Format.Alignment = wdAlignParagraphLeft
End If
Next i

End Sub

The StatusBar line is there to provide some visual feedback as the macro works its way through a file. Execution is not objectionably slow, but it's far from blazing fast. (Assigning the paragraph count to the variable j is done to keep things from slowing down even further by having to call oSource.Paragraphs.Count for each value of i.)

Cheers...

Profile

alexpgp: (Default)
alexpgp

January 2018

S M T W T F S
  1 2 3456
7 8910111213
14 15 16 17181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 24th, 2025 06:33 am
Powered by Dreamwidth Studios