Reputation: 10841
I have some MS-Word 2013 documents containing Microsoft Equation 3.0 equations. Unfortunately, the equations change size from time to time, whether by accident or perhaps due to a bug in Word.
To address this, I wrote a VBA macro to fix the sizes of all the equations in the document back to their original sizes, as follows:
Sub FixEquationSize()
Dim shp As InlineShape
For Each shp In ActiveDocument.InlineShapes
shp.ScaleHeight = 100 'The value of ScaleHeight is a percentage
shp.ScaleWidth = 100
shp.LockAspectRatio = msoFalse
shp.Reset
Next
End Sub
... however this fixes the height and width of all InlineShape
objects, not just the ones that are equations.
A previous question and answer found equations in Word by iterating through ActiveDocument.OMaths
, but that solution found equations created by Insert|Symbols|Equation
, not equations inserted by Insert|Text|Object|Microsoft Equation 3.0
(it is interesting that they are different!).
If I have to iterate through InlineShapes
, how could I distinguish InlineShape
objects that are equations from those that are not?
Upvotes: 1
Views: 837
Reputation:
Equation 3.0 equations are embedded OLE objects (unlike the newer type of equation which uses a different mechanism. So something like
If shp.Type = wdInlineShapeEmbeddedOLEObject Then
If shp.OLEFormat.ClassType = "Equation.3" Then
' it's an equation object
End If
End If
This assumes that you haven't converted the shapes to something else, e.g. copied/pasted as a graphic of some kind.
Upvotes: 3