在文档中插入根号的两个简洁代码 (VBA)

Sub InsertReq1() '方法一 Dim Insertvalue As String On Error Resume Next With Selection If .End > .Start Then Insertvalue = IIf(Selection Like "*" & Chr(13), Range(.Start, .End - 1), Selection) .Delete Application.Run "InsertFieldChars" .InsertAfter "Eq /r(2," & Insertvalue & ")" End If .Fields.ToggleShowCodes End With End Sub '---------------------- Sub InsertReq2() '方法 2 With Selection If .Type = wdSelectionNormal Then _ : .Text = "Eq /r(2," & IIf(InStr(Selection, Chr(13)) > 0, Range(.Start, .End - 1), Selection) & ")" _ : Application.Run "InsertFieldChars" _ : .Fields.ToggleShowCodes End With End Sub

你可能感兴趣的:(String,文档,VBA)