View Single Post
 
Old 08-20-2020, 05:14 PM
puff puff is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Question [Code attached] Macro can only be triggered inside editor but not shortcut keys

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!
Reply With Quote