Share via

Macro for inserting equation - Problem with Crossreference (only Label and Number)

Anonymous
2016-02-26T14:35:57+00:00

Hello,

I have created a macro for adding an equation in according to a predefined format which works perfect (see code below).

The only problem is that if I would like to set a cross reference to the related SEQ field (related Caption is defined), it takes the entire equation including the equation number instead of only Label and number. How is the label defined?

Thanks for comments


Sub InserEquation()

With Selection

        .Style = ActiveDocument.Styles("Equation")

        .TypeText Text:=vbTab

        .InlineShapes.AddOLEObject ClassType:="Equation.3", _

                                   LinkToFile:=False, _

                                   DisplayAsIcon:=False

        .TypeText Text:=vbTab & "Eq. ("

        .Fields.Add Range:=Selection.Range, _

                    Type:=wdFieldEmpty, _

                    Text:="SEQ Equation \*MERGEFORMAT", _

                    PreserveFormatting:=False

        .Fields.Update

        .TypeText Text:=")"

        .TypeParagraph

    End With

End Sub


Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2016-02-26T16:03:26+00:00

Word adds a hidden bookmark around the caption when you insert the cross reference.

It's a bit of a mess to fix it, as the Add Bookmark dialog does not let you work with those.

But you can use my Bookmark Manager to set it the way you want. Read the help file for instructions.

See http://insight.trueinsight.za.com/word/word-utilities/

b.t.w. the uTIlities contain a tool that adds a new oMath equation to your document. Description of the process here:

http://insight.trueinsight.za.com/numbered-equations-in-word/

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful