Add a horizontal bar above a letter
Add a horizontal bar above a letter
(OP)
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 ' Selection.OMaths(1).Functions.Add(Selection.Range, wdOMathFunctionBar).Bar _ .BarTop = True 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.
RE: Add a horizontal bar above a letter
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
RE: Add a horizontal bar above a letter
I want to be able to add a bar over a letter from time to time. I presume it is called a "macron".
Alex
RE: Add a horizontal bar above a letter
CODE
Sub InsertA_macron() Selection.InsertSymbol Font:="Arial", CharacterNumber:=256, Unicode:=True End Sub
and I am sure you can pass a different CharacterNumber(s) to get other letters as well
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
RE: Add a horizontal bar above a letter
Yes, it works, but that's not exactly what I need.
I need, while typing a text, to type at any point of time, any letter, with a line above it (as if I was using an accent for example).
If I use your suggestion, I will have to use 26 shortcut keys, one for each letter of the alphabet.
RE: Add a horizontal bar above a letter
In Word, perhaps the simplest method for upper-case macrons is to type the character requiring the macron (eg X), then type 0305, so you end up with X0305, then select the 0305 and press Alt-X. With that, you should get a bar over the X. For lower-case characters (eg i), you can use 0304, and get With that, you should get a bar over the i. For double bars over a character, you can use 033F (the gap between the double lines may be indistinct over some letters).
Word fields can also be used to place a diacritic over any letter, and can thus be used for macrons and vinculums alike:
• use a field coded as {EQ \x\to(a)}. This solution increases the vertical spacing for the affected line (which you could get around by reducing the field’s point size).
• use a field coded as {EQ \o (-,a)}. To achieve the desired result, superscript the first character in the field and subscript the second character, which leads to small characters for both (which you could counter by increasing the point size), but this too increases the vertical spacing for the affected line … Note: if you have more than one subscripted character, you’ll need to compensate by increasing the # of superscripted characters and there’ll invariably be gaps between them.
• use a field coded as {EQ \s\up6(\f(,a))}. Compared to the other solutions, this one has the advantage of retaining the character sizes without increasing the line height. The ‘6’ in the formula controls the bar height.
In each example, replace the ‘a’ in the field with the desired character(s).
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.
The following macro implements the last of the above examples for a selected string:
CODE
Cheers
Paul Edstein
[Fmr MS MVP - Word]
RE: Add a horizontal bar above a letter
It works beautifully.
Thank you so nuch!
Alex