Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

How to add an IF statement to Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al - 17 Jan 2006 22:32 GMT
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
Tony Jollans - 18 Jan 2006 00:35 GMT
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

--
Enjoy,
Tony

> I have a Word 2002 document produced from an external application with
> many Equation editor objects.  However, the equations do not properly
[quoted text clipped - 30 lines]
>     End With
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.