Hi. I have a macro below and it's assigned to Ctrl + Shift + =.
Code:
Sub Test()
With Selection
If .OMaths.Count = 0 Then 'This means the selection isn't inside a formula
.TypeText Text:=" "
.MoveLeft Unit:=wdCharacter, Count:=1
.Font.Superscript = wdToggle
Else 'Anything that isn't 0 means you're selecting something inside a formula
.OMaths(1).Functions.add Range:=Selection.Range, Type:=wdOMathFunctionScrSup
.MoveRight Unit:=wdCharacter, Count:=1
End If
End With
End Sub
For normal texts, the shortcut keys work. However, the shortcut keys don't work for formulas--instead I have to trigger it from the editor. Could someone have a look and help solve this issue? Thanks!