Aug 4, 2012

Examining embedded objects in Microsoft Word

Recently I described a method for translating embedded objects in Microsoft Office documents. The final step in that method requires these objects to be refreshed by opening them manually or using a corresponding macro.

The macro below is intended for inspecting all the embedded objects in a Microsoft Word document. When run, it opens each of these objects if possible, regardless of type, and leaves the corresponding editing window open. This allows last minute changes to be made conveniently before the objects are saved and refreshed in the document view. A similar approach can be used for objects embedded in Excel or PowerPoint, though the references are a little different.

This macro could also be used to test quickly whether a large document has embedded objects to be dealt with. Sometimes it's hard to recognize these. It does not, however, open bitmaps inserted as pictures.
Sub openEmbeddedObjects()
   Dim longShapeCount As Long
   On Error Resume Next
   Application.ScreenUpdating = False
   longShapeCount = ActiveDocument.InlineShapes.Count
   If longShapeCount > 0 Then
      For i = 1 To longShapeCount
        ActiveDocument.InlineShapes(i).OLEFormat.Edit
      Next
   End If
   Application.ScreenUpdating = True
End Sub



No comments:

Post a Comment

Notice to spammers: your locations are being traced and fed to the recreational target list for my new line of chemical weapon drones :-)