Home > Articles > Computer Software > Business Office Software > Desktop Publishing Software > Microsoft Word

This chapter is from the book

Viewing Total Editing Time Updated in Real-Time

The total amount of time that a document has been edited is useful for freelancers, lawyers, consultants, and other professionals who bill for their time. Knowing how long you have spent working on a document enables you to provide a more accurate accounting of your time.

If you have a time budget that you're trying to stick to, you may find yourself constantly checking the document's Properties dialog box to view the Total editing time value. Rather than wasting time performing that chore, add the EditTime field to your document. Word's EditTime field displays the total time, in minutes, that the document has had the system focus (and, presumably, has been edited) since the time at which the document was created. This is the same as the Total editing time value displayed in the Statistics tab of the document's Properties dialog box.

Follow these steps to add some code that displays the total editing time with the word minutes added for clarity:

  1. Type some descriptive text (such as Total Editing Time:).
  2. Press Ctrl+F9 to start a new Word field (signified by the { and } braces).
  3. Between the field braces, type the following:
    EDITTIME \# "0 minutes" \* mergeformat
  4. Press F9 to complete and update the field.

Now all you have to do is update the field to check the total editing time.

If even that sounds like a hassle, you can add a relatively simple macro to the document that will update the EditTime field in real-time. Open the Visual Basic Editor and insert a module in the document's project. Add the code in Listing 3.10 to the module.

Listing 3.10. Updating the EditTime Field in Real-Time

Public Sub UpdateEditTime()
    Dim f As Field
    For Each f In ThisDocument.Fields
        If f.Type = wdFieldEditTime Then
            f.Update
        End If
    Next 'f
    Application.OnTime Now + TimeValue("00:01:00"), "UpdateEditTime"
End Sub

This procedure runs through all the fields in the document looking for one where the Type property is wdFieldEditTime, which corresponds to the EditTime field. When the property is found, the Update method refreshes the field. The key to the real-time updating is the Application.OnTime statement, which sets up the UpdateEditTime procedure to run again in one minute. Note that you'll probably need to adjust the project name ("Chapter03") and the module name ("Chapter3") to match the name of your project and module.

  • + Share This
  • 🔖 Save To Your Account