您的当前位置:首页正文

word文档公式编辑宏代码

2020-12-14 来源:独旅网


Sub 分数()

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

PreserveFormatting:=False

x = InputBox(\"请输入分母\")

y = InputBox(\"请输入分子\")

ss = LenB(StrConv(x, vbFormUnicode))

ss = ss / 2

Selection.TypeText Text:=\"eq \\f()\"

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=x

Selection.MoveLeft Unit:=wdCharacter, Count:=ss

Selection.TypeText Text:=\

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=y

Selection.Fields.ToggleShowCodes

End Sub

Sub 向量()

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

PreserveFormatting:=False

x = InputBox(\"请输入向量名称\")

Selection.TypeText Text:=\"eq \\o()\"

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=\"\\s\)\"

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=\"→\"

Selection.MoveRight Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=\

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=x

Selection.Fields.ToggleShowCodes

End Sub

Sub 开方()

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

PreserveFormatting:=False

x = InputBox(\"请输入被开方数\")

Selection.TypeText Text:=\"eq \\r()\"

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=x

Selection.Fields.ToggleShowCodes

End Sub

Sub 方程组()

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

PreserveFormatting:=False

n = InputBox(\"请输入方程的个数\")

Selection.TypeText Text:=\"eq \\b\\lc\\{()\"

Selection.MoveLeft Unit:=wdCharacter, Count:=1

Selection.TypeText Text:=\"\\a()\"

Selection.MoveLeft Unit:=wdCharacter, Count:=1

k = 0

For k = 1 To n - 1 Step 1

a = InputBox(\"请输入第k个方程\")

Selection.TypeText Text:=a

Selection.TypeText Text:=\

Next k

a = InputBox(\"请输入最后一个方程\")

Selection.TypeText Text:=a

Selection.Fields.ToggleShowCodes

End Sub

Sub 组合()

Selection.TypeText Text:=\"C\"

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

PreserveFormatting:=False

x = InputBox(\"请输入组合数上标\")

y = InputBox(\"请输入组合数下标\")

Selection.TypeBackspace

Selection.TypeText Text:=\"eq \\o\\al(\\s\"

Selection.Font.Superscript = wdToggle

Selection.TypeText Text:=x

Selection.Font.Superscript = wdToggle

Selection.TypeText Text:=\"),\"

Selection.Font.Subscript = wdToggle

Selection.TypeText Text:=y

Selection.Font.Subscript = wdToggle

Selection.TypeText Text:=\")\"

Selection.Delete Unit:=wdCharacter, Count:=1

Selection.Fields.ToggleShowCodes

End Sub

Sub 弧()

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

PreserveFormatting:=False

x = InputBox(\"请输入弧的名称\")

Selection.TypeBackspace

Selection.TypeText Text:=\"eq \\o(\"

Selection.Font.Italic = wdToggle

Selection.TypeText Text:=x

Selection.Font.Italic = wdToggle

Selection.TypeText Text:=\

Selection.InsertSymbol CharacterNumber:=-459, Unicode:=True

Selection.TypeText Text:=\"))\"

Selection.Delete Unit:=wdCharacter, Count:=1

Selection.Fields.ToggleShowCodes

End Sub

因篇幅问题不能全部显示,请点此查看更多更全内容