MTRecognition Word edition - restoring broken equations in MS Word

WRec is an add-on to the mathematical equation recognition service that allows you to restore (by recognition) equations that have turned into regular images directly in Word.

Let's look at the process of equation recovery step by step.

  1. Download archive.
  2. Copy folder WRec from zipped archive with all its content to disk C. (ONLY TO DISK C OR YOU MUST DO APPROPRIATE CHANGES IN MACRO!)

This folder contains the program WRec.exe and the initialization file WRec_.ini. It is a plain text file.

Here are its contents.


Instead of zeros in line with ID you should write email, and instead of zeros in line with KEY you should write access code.

The access code for all components of the MTRecognition service is unified. It can be obtained free of charge for testing by emailing The test key allows you to recognize up to 100 equations.

  1. VERY IMPORTANT! MAKE SURE that your Word document does not contain any $ symbol. This should be done before you begin equation recovery. If $ is found in the text, remove or replace it with other characters or character combinations, otherwise it will not be possible to properly convert equations from TeX to MathType.
  2. At the bottom of this page, the code for the WTRec_Restore script is given in plain text. This text simply needs to be copied from this page and placed in Word.

Let's look at two ways to do this.

First option. Open Word, click on View in the menu. In the panel that opens, click on MACROS and select MACROS RECORD. A dialog box will open. It doesn't matter what the name of the macro will be. Leave the default name. The macro must be written in Normal.dotm. Click OK. This will start the recording. Immediately afterward, click on MACROS again and choose Stop Recording. Now click on MACROSES again and choose MACROS from the drop-down menu. Select the macro you just recorded and click CHANGE. The Microsoft Visual Basic window will open and you will see the code like this one: SUB MACROS1 END SUB. Select everything from SUB to END SUB and paste the text of the WTRec_Restore macro instead (see it below).

Second option. Open Word, click on the Developer tab in the menu. If you don't have one, follow the instructions on the Microsoft website - how to show Developer Tab in Word. Click on Visual Basic. In the window on the left, find the Normal item, open it, open the Modules item and click on New Macros. In the main window on the right, enter the text of the macro. Now, if you close the Microsoft Visual Basic window and click on MACROS (Alt+F8), you should see WTRec_Restore in the list of macros.

  1. Select all the text or part of it in MS Word where you want to restore equations and run the script. To do this, press Alt + F8 and press WTRec_Restore.
  2. The original images with the equations will remain unchanged, and the recognized equations in TeX format will be inserted in front of them. You can remove images with uneditable equations by replacing ^g with an empty character. They are left on, so you can check if the recognition is correct.
  3. To convert equations to MathType format, select the desired portion of text and run the MathType -> Toggle TeX menu command. If there are too many equations, the conversion will fail.

Select the smaller portion of the text and repeat the conversion.

Macro WTRec_Restore

Sub WTRec_Restore()
Dim iShape As InlineShape
Dim Seconds, CurrentTimer, iCount As Long
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
Dim errorCode As Integer
For Each iShape In Selection.InlineShapes
  iShape.Height = iShape.Height * 2
  iShape.Width = iShape.Width * 2
  iShape.Height = iShape.Height * 0.5
  iShape.Width = iShape.Width * 0.5
  errorCode = wsh.Run("C:\WRec\WRec.exe", windowStyle, waitOnReturn)
  Seconds = 0.1
  CurrentTimer = Timer
  Do While Timer < CurrentTimer + Seconds
Next iShape
End Sub