The Translation Outpost

A project of Alex Lane and Galexi Wordcraft, LLC

User Tools

Site Tools


Sidebar


“Without his exceptional skill and adeptness at translation and interpretation, our communication and coordination with our Russian Federation counterparts would have been impossible.“ – L. E. Olsen, Capt., USN


blog:finding_errors_in_fields

Finding errors in fields

So the other day, I used an old translation as a template for a new translation, and after making all of the suitable changes and performing my QC, the document was sent off, along with the other documents of the assignment.

The old translation was old enough for me not to remember that I had used bookmarks and fields in the document, and even though my revision had “stepped on” a bookmark that occupied a table cell (I replaced the bookmarked contents with new contents), the document looked completely normal on my screen. As it turned out, it looked okay on the editor's screen as well.

It looked right on the end client's screen, too, until he tried to print it, whereupon the message Error! Reference source not found appeared in several places in the one-page document.

Oops.

In the end, the problem didn't cause any major ripples, and it was solved in short order. In the aftermath, however, it occurred to me that perhaps I should start printing documents as part of my QC process (no actual printing is necessary; it's enough to simple select File | Print and the print preview will show the error), but then I realized this would only help for short documents. So, after digging a bit on the Internet and my VBA manual, I came up with a macro that informs me if a field update is successful or not.

Sub UpdateFields()

  If ActiveDocument.Fields.UpDate = 0 Then
   MsgBox "Fields updated successfully!"
  Else
   MsgBox "There is a field with an error!"
  End If
  
End Sub

According to the Microsoft Office Dev Center Documentation, the ActiveDocument.Fields.UpDate method updates all the fields in the main body of the active document, returning the value zero if everything is okay or the index of the first field that contains an error.

After experimenting, however, I found that if a field contains an error, the method pretty consistently returns the value -1 (instead of an index to a field), which means that if the macro reports the existence of a field with an error, you'll have to search for the string Error! inside the document to find it.

Suggestions for improvement to the macro are welcome!

blog/finding_errors_in_fields.txt · Last modified: 2015/03/06 21:24 by galexiadmin