简体   繁体   English

如何从显示模式方程式分辨出MS文字段落

[英]How to tell a MS word paragraph from a display-mode equation

I want to use VBA to do something about a normal MS word paragraph. 我想使用VBA对普通的MS Word段落进行处理。 But a display mode equation looks just like a paragraph. 但是显示模式方程看起来就像一段。 Can anybody tell me, please, the difference between them? 有人可以告诉我他们之间的区别吗? Or provide a VBA example to distinguish them. 或提供一个VBA示例来区分它们。

在此处输入图片说明

Function IsADisplayModeEquation(ParagraphIndex As Long)
    Dim ParagrapLineNum As Long
    Dim EquationLineNum As Long
    ParagrapLineNum = ActiveDocument.Paragraphs(ParagraphIndex).Range.Information(wdFirstCharacterLineNumber)

    n = ActiveDocument.Bookmarks("\page").Range.OMaths.Count
    For I = 1 To n
        EquationLineNum = ActiveDocument.Bookmarks("\page").Range.OMaths(I).Range.Information(wdFirstCharacterLineNumber)
        If (ParagrapLineNum = EquationLineNum) And ActiveDocument.Bookmarks("\page").Range.OMaths(I).Type = wdOMathDisplay Then
            IsADisplayModeEquation = True
            Exit Function
        End If
    Next I
    IsADisplayModeEquation = False
End Function

A ugly function: 丑功能:

Function IsADisplayModeEquation(ParagraphIndex As Long)
    Dim ParagrapLineNum As Long
    Dim EquationLineNum As Long
    ParagrapLineNum = ActiveDocument.Paragraphs(ParagraphIndex).Range.Information(wdFirstCharacterLineNumber)

    n = ActiveDocument.Bookmarks("\page").Range.OMaths.Count
    For I = 1 To n
        EquationLineNum = ActiveDocument.Bookmarks("\page").Range.OMaths(I).Range.Information(wdFirstCharacterLineNumber)
        If (ParagrapLineNum = EquationLineNum) And ActiveDocument.Bookmarks("\page").Range.OMaths(I).Type = wdOMathDisplay Then
            IsADisplayModeEquation = True
            Exit Function
        End If
    Next I
    IsADisplayModeEquation = False
End Function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM