Hi,
I am trying to create a function in Word 365 to add a horizontal bar above a letter.
I used a record macro, and succeeded for the first attempt only.
The first time I use it, it works:
¯A
(it does'nt appear correctly here, but in word, the bar is just above the letter "A")
But if I try it again, I get:
Run-Time error'5941':
The requested member of the collection does not exist.
Could anyone help me generalise this macro?
Thank you.
I am trying to create a function in Word 365 to add a horizontal bar above a letter.
I used a record macro, and succeeded for the first attempt only.
The first time I use it, it works:
¯A
(it does'nt appear correctly here, but in word, the bar is just above the letter "A")
But if I try it again, I get:
Run-Time error'5941':
The requested member of the collection does not exist.
Code:
Sub BarTop()
'
' BarTop Macro
' Add a horizontal bar above a letter
'
[highlight #FCE94F]Selection.OMaths(1).Functions.Add(Selection.Range, wdOMathFunctionBar).Bar _
.BarTop = True[/highlight][highlight #FCE94F][highlight #FCE94F][/highlight][/highlight]
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Font.Italic = wdToggle
Selection.Font.ItalicBi = wdToggle
Selection.OMaths(1).ParentOMath.Justification = wdOMathJcLeft
End Sub
Could anyone help me generalise this macro?
Thank you.