Skip to content

Instantly share code, notes, and snippets.

@kolipass
Created February 16, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolipass/e5381a45894ffd01437d3bf8d30730b7 to your computer and use it in GitHub Desktop.
Save kolipass/e5381a45894ffd01437d3bf8d30730b7 to your computer and use it in GitHub Desktop.
Sub updateFormulsTextSyle()
On Error Resume Next
Dim F As Word.Field
Dim N1 As Long, N2 As Long
Application.ScreenUpdating = False
N1 = 0: N2 = 0: N3 = ActiveDocument.Fields.Count
percent = ""
For Each F In ActiveDocument.Fields
If F.Type <> Word.wdFieldEmbed Then
ElseIf Not (F.OLEFormat.ClassType Like "Equation.*") Then
Else
N1 = N1 + 1
Err.Clear
F.OLEFormat.ConvertTo ClassType:=F.OLEFormat.ClassType
If Err.Number <> 0 Then ' ошибка
N2 = N2 + 1
Application.ScreenUpdating = True
F.Select
Select Case MsgBox(Prompt:="Ошибка! " & vbLf & vbLf & _
"Нет возможности обработать формулу типа: " & vbLf & _
F.OLEFormat.ClassType & vbLf & vbLf & _
"Продолжить?", _
Buttons:=VBA.vbCritical + VBA.vbYesNo)
Case VBA.vbOK, VBA.vbYes
Case Else: Exit For
End Select
Application.ScreenUpdating = False
End If
End If
tempP = Format(N1 / N3 * 100, "0")
If Not percent = tempP Then
percent = tempP
StatusBar = "Обработано: " & percent & "%"
End If
Next F
Application.ScreenUpdating = True
StatusBar = "Обработано формул: " & N1 & ", ошибок: " & N2
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment