alexpgp: (St. Jerome w/ computer)
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.)


What a day!

Nov. 7th, 2014 08:00 pm
alexpgp: (Aaaaarrrggghhhhhh!!!!!!!)
I had hoped to spend this morning doing some additional QC on the 400-pager that was due just after lunch, but it turns out that when my translation memory software "reassembled" the Word file for delivery, it apparently did not restore the position of over 3,000 small graphics that peppered 50,000-word the text.

Those graphics represented mathematical expressions ranging from the very simple to rather complex. And since they also included graphics of Latin characters (such as 'M' and 'Q'), I have to assume that whatever OCR software was used to create the original file was not configured to recognize multiple languages at the same time (something that FineReader handles quite well). In addition, the original file also used the graphics for superscripts.

What makes the source file really extraordinary (and makes me feel sorry for whoever put the file together), is that each graphic has been individually "tweaked" to sit several points below where it normally would were it allowed to simply sit on a line with the text around it. This was done to align the content of the graphic more or less with the surrounding text.

In any event, in the end, the only way to get the job done was to create a Word macro that dropped whatever was selected by 1.5 points (most of the graphics would require two iterations to property align the graphic, some three, a few only one, and about 200 of them (display equations) required 8 or so). Word's ability to assign a key chord to macro execution came in handy, too.

The code looks like this:
Sub Lowerby1dot5pt()
' Lowerby1dot5pt Macro
' Reposition the selection 1.5 points below its current
' position with respect to surrounding text
  With Selection.Font
    .Name = "Times New Roman"
    .Size = 12
    .Spacing = 0
    .Scaling = 100
    .Position = .Position - 1.5
    .StylisticSet = wdStylisticSetDefault
    .ContextualAlternates = 0
  End With
End Sub
Of course, creating a macro was me just "sharpening the saw" for the big push. I then basically went through the whole file and turned into an automaton that clicked on graphics and then chorded my keyboard as many times as was necessary to align the graphic. There were times, during the process, that I thought I'd not finish in time, and my mental response to myself was to say that I'd deliver what I had when the time came, whereupon I did my best to put it out of my mind. In the end, I managed to get through the file, but it took a lot out of me.

I'm not tremendously worried about the QC (he said, with fingers crossed) because I took particular care to make sure things were as right as possible before exporting the final candidate document.

I didn't do very much at all the rest of the day. I tried to take a nap, and I think I did drift off, briefly, but I was too wound up to really relax. I wanted to go out to eat to celebrate, but as I drove off in the car, I really didn't feel hungry, so I eventually got back home with a steak that I had picked up, which I plan to cook tomorrow, and did a little tai chi. I found it hard to let go of the events of the day, however. Better luck next time.

alexpgp: (Default)
Back when I helped manage a translation shop, one of the Prime Directives (there were several) issued to translators was to not use Microsoft Word's auto-numbering feature, as it generally created more problems than it solved. The only fly in that ointment had to do with how so many Russian source documents did use the feature (even if it required the Russian originator of the document to do unspeakable things with formats and options to make the end result look right).

I still am averse to the use of auto-numbering (which includes auto-alphabetization), so I was tickled to discover, some time ago, the following one-line macro:
Sub ConvertNumToText()
End Sub
The biggest problem I had implementing the macro had to do with, basically, nothing much happening as a result of running it, except that now what used to be autonumbers, etc. are now fully editable.

Restoration of my lost macros proceeds, and as is (unfortunately) usually the case when I've had to go back and reconstruct code, I'm coming up with better and more robust code this second time around.

alexpgp: (St. Jerome w/ computer)
When a document is displayed in revision mode, it is sometimes difficult to make sense of what the final result is supposed to look like, because either you can't tell if a character has been struck through (my preference) or because the revisor was in a playful mood or suffers under the delusion that the computer can generate only a limited number of letters and thus, new text must reuse as many previous letters as possible (even if the resulting revised text cannot be read without suppressing what has been deleted).

And thus, the first of my "reconstituted" macros, what amounts to a one-liner that toggles the DeletedTextMark option:
Sub ToggleRevModeDisplay()
If Options.DeletedTextMark = wdDeletedTextMarkHidden Then
    Options.DeletedTextMark = wdDeletedTextMarkStrikeThrough
    Options.DeletedTextMark = wdDeletedTextMarkHidden
End If
End Sub
alexpgp: (Barcode)
As time goes by and my translations come more fluidly, it occurs to me that the ratio of time spent formatting to the time spent translating has gone up. Several months ago, I created a set of Styles in Word that reflected the formatting desires of the end client, and since then, the need to pause and take care of things that—frankly—can be automated seems to weigh ever heavier on my psyche.

Take, for example, the task of creating footers. The client likes to see a footer with "Received on MM/DD/YY" in the lower left corner, and a page number in the lower right corner. The conventional way to go about doing this is to click on the Insert tab on the Ribbon, then on Footer, then on Edit Footer, at which point—if your machine is like mine, you've experienced two pauses while code loads—you're ready to make sure the footer is 0.5 inch from the bottom of the page and, of course, to start actually typing the silly text! Inserting the page number involves some more mouse clicks.

There is a better way. With any luck, my comments in the following VBA code ought to be self-explanatory.
Sub Insert_Client_Footer()
' Insert a client-specific footer in the ActiveDocument

' Execute code at Handler if Style not present
On Error GoTo Handler

   ' Set footer distance to 0.5 inch.
   ActiveDocument.PageSetup.FooterDistance = InchesToPoints(0.5)

   ' Select the footer in the document's first section.
   ' (This will need tweaking for multi-section docs where footers
   ' in later sections do not "link to previous" footers.)
   ActiveDocument.Sections(1) _

   ' Delete whatever information was in the previous footer

   ' Apply the style (loaded previously) and construct the footer
   With Selection
      .Style = "Client-Footer-Style"
      .TypeText "Received on "
      .TypeText Date
      .TypeText vbTab
      .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
         Text:="PAGE "
   End With
Exit Sub

' If the Client-Footer-Style is not present, it will be added
' and execution will resume. The correct style will display when
' a style sheet with the Client-Footer-Style is loaded.
   If Err = 5834 Then
      ActiveDocument.Styles.Add _
         Name:="Client-Footer-Style", Type:=wdStyleTypeParagraph
   End If

Doubtless, there are other tweaks that might become worth my while to implement should not having them start to bug me (e.g., returning the cursor to the original insertion point after running the macro DONE! Leave a comment if you're interested. :^).

One step at a time, that's the ticket!

P.S. UPDATED 04/17 to "zero out" the contents of the previous footer.


alexpgp: (Default)

October 2017

1 2 3 45 67
8 9 10 11121314
15 161718192021


RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 17th, 2017 04:36 pm
Powered by Dreamwidth Studios