How to add an IF statement to Macro

A

Al

I have a Word 2002 document produced from an external application with
many Equation editor objects. However, the equations do not properly
line up with the other text on the line. If I select an equation and open
the Equation editor then close it without making any changes, the
misalignment gets corrected. I need a macro to go through the document
and for each Equation Editor object, open Equation Editor and close it.
I recorded a macro to do this with Find ^g. (I did get help with the
SendKeys to close the application). It works OK until it finds a graphic
which is not Equation Editor then halts. I think I need to add
something like this:
If .Type = msoLinkedOLEObject Then
If .OLEFormat.ClassType = "Microsoft Equation 3.0" Then

But I cannot figure out where and how to do this.
Your help is greatly appreciated.

Sub OpenCloseEqEd()
'
' Macro recorded 2/4/2004
Application.DisplayAlerts = wdAlertsNone
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
Do While .Execute
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=1
With Selection.Application
SendKeys "%fx", True
End With
Loop
End With
End Sub
 
T

Tony Jollans

Something like this ...

Do While .Execute
With Selection.InlineShapes(1)
If .Type = wdInlineShapeEmbeddedOLEObject Then
If .OLEFormat.ClassType = "Equation.3" Then
.OLEFormat.DoVerb VerbIndex:=1
With Selection.Application
SendKeys "%fx", True
End With
End If
End If
End With
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top