Another Word macro...
Mar. 30th, 2015 08:29 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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:
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...
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...