About Me


Sunday 13 March 2016

More on RTL – A Font Macro Bug fixed with (a) Style


Yet another RTL comment. I’ve been looking forward to sharing other kinds of discoveries, but I keep encountering problems/features with the Office 2016 Mac implementation of RTL.

Today I will discuss how to set up your system so that you can change fonts and keyboards with a single keystroke.

Assign a Shortcut Key to the LTR/RTL buttons
Office 365/2016 Mac does have Shortcut Keys assigned to these buttons by default, but it is a good idea to do so, especially if you would like to include the command as part of a Macro.
1.     Go to Tools/Customise Keyboard.
2.    Under Categories, choose Format
3.    In the Commands box, scroll down to LtrPara and assign a Shortcut Key. Do the same for RtlPara.

Record Macro. A Macro is a program, a set of instructions telling the computer what to do. Microsoft Office provides a programming language called Visual Basic for Applications, a.k.a. VBA. But Microsoft has provided something more. We don’t need to program using VBA; we can ‘Record’ a Macro. The overall concept is to start Record Macro, type what we want, including shortcut keys, then Stop Recording.

Macros will only record keystrokes (with certain exceptions). For example, if we want to bring up the Font Menu to change fonts, we must use Cmd + D or Cmd + Shift + F (both work). Record Macro will not recognise Format/Font.

To begin, find Record Macro by going to Tools/Macro/Record Macro. Alternatively, before recording, Show the developer tab.
1.    On the Word menu, click Preferences.
2.    Under Authoring and Proofing Tools, click View.
3.    Under Ribbon (at the bottom of the menu), check the Show developer tab box.
After you show the tab, it stays visible in your ribbon, unless you clear the check box or have to reinstall a Microsoft Office program.

Next we will Record a Macro that sets the shortcut key, control (cntl) + 8 to change the font to Ezra Sil 14pt.

1.    Developer/Record Macro.
2.    Give your Macro a Title (no spaces)
3.    Assign a keyboard shortcut not otherwise used: press control (cntl) + 8
4.    Bring up the Font Menu with cmd + D
5.    Change the Font to Ezra Sil 14
6.    Stop Recording

Here is a video of the process and how control (cntl + 8) change the font.



If you go to Developer/Macro and highlight the Macro entitled Ezra Sil, then press Edit, you will see the VBA of your Macro. Here are the first vew lines.

' EzraSil Macro
'
'
    With Selection.Font
        .Name = "Ezra SIL"
        .Size = 14
        .Bold = False
        .Italic = False
       

With a program like Keyboard Maestro, we can insert this Font Macro (via cntl + 8) into another Macro, which will change the keyboard at the same time.

But before providing these instructions…there is a Bug!!!

Changing a Font with a Macro Aborts when an RTL language is activated
As I have shown over the last two posts, an RTL language is set if you can see the LTR/RTL buttons. In the recording above, you can see that there are no buttons, so RTL is ‘off’. Here is what happens when you try to create Font Change Macro when the buttons are on, using the same instructions as above.




As you can see from the first few lines, even though I changed the font to Ezra Sil, it issues three strange commands related to Times New Roman, and these cause the error. Notice how they differ from the earlier Macro.

With Selection.Font
        .NameFarEast = "Times New Roman"
        .NameAscii = "Times New Roman"
        .NameOther = "Times New Roman"
        .Size = 14
        .Bold = False

This does not occur with RTL in Windows Office 2016. The problem seems to be related to the font, because other kinds of Macros I tested work fine.

Solutions – I know of two workarounds, so far.

Option 1 – Create all your Font Macros with RTL off. This is not entirely crazy. Those Macros generated when an RTL is not activated will still work when one is set.

Option 2 – Don’t use Macros for the font changes; rather create a new Character Style with a Shortcut Key.

Good basic articles on what styles are and how they work are two by Shauna Kelly. She passed away in 2011, but I have read many of her articles and they remain extraordinarily helpful. These articles about Windows Office, but the concepts are the same: http://shaunakelly.com/word/styles/stylesms.html and http://shaunakelly.com/word/styles/howstylescascade.html and one by Microsoft: https://support.office.com/en-gb/article/Apply-change-create-or-delete-a-style-1a2cead9-897f-48a7-9122-7849d3b5030a

Option 2 - Create a New Font Style
1.     On the Home tab click on the Styles Pane



2.    Choose New Style.

3.    A window will pop up.



4.    Change the name, Style1, to something that will help you find it, like Ezra Sil. You can use spaces.

5.     This is Very Important – Change the style type from Paragraph to Character. Otherwise you will not be able to have two different fonts in the same sentence or paragraph, which is defined as anything before you hit return. Trust me on this. The explanation is tedious.

6.    Leave Style based on as Default Paragraph font that appears when you set the Style type to Character.

7.     Then in Formatting, change the Font and Pointing to what you want for this Font Style. If this is for an RTL language, click the button that defaults to Latin, and change it to Complex. This is very important, otherwise Word will not recognise it as a Complex font and will automatically change to the default Complex font found in Format/Font.  

8.    At the bottom of the menu make sure you tick Add to Template, if you want to use this Style for other documents, which your probably do. I do not bother with the Add to Quick Style Gallery, because it is redundant if you set a shortcut key, as in the next instruction. What it does is place this style in the Quick Style Pane, the pictures to the left of the Styles Pane. Here is my Ezra Sil 14.



9.    Next, in the lower left corner, there is a button labelled Format. Click this and button and click Shortcut Keys. Choose a Shortcut Key combination.

10.  You will also want to set a Character Style with shortcut key for your preferred English Font.

11.   Repeat the above for all fonts that you will want. Make sure to include an English font as well. This font is likely already in the Normal Paragraph style, but clicking on this will not change the font if the Character Style is set to Styles Based on: Default Paragraph Style.

12.  To modify or delete this or any Style, you can go to Tools/Style and choose your preference. Alternatively, in the Styles Pane, find the Ezra Sil style. It as a small ‘a’ on the right in blue. However over it, and a button will appear. Click the button, and another menu pops up that allows you to modify or delete. BTW, the little ‘a’ means it is a Character Style, while a backwards ‘p’ (remember, ‘pilcrow’), a Paragraph Style.


Macro to Keyboard and Font - The Keyboards in the Apple Mac Input Menu are not accessible by a Macro in Microsoft Word; those can only control things in Word. But programs like Keyboard Maestro are designed for this.

Here is my Macro for Hebrew. Yes, it’s only two commands. Simple eh?



Now, here is my Macro for switching back to English. Notice the additional instruction, control (cntl) + L (KM puts the ‘L’ in uppercase, even though there is no shift). This is my Shortcut combination for the LTR button.




Third party or Customised Keyboards like Syriac and Hebrew TH (Tyndale House) – As discussed above, Office 2016 Mac, even Version 15.20, does not recognise these Keyboards as RTL.

Solution – The workaround is the same one discussed on Monday, 7 March 2016. First activate an RTL Keyboard that from the Apple Mac bundle. Then execute activate the Customised Keyboard.

Here is my KM Macro to accomplish. cmd + E and cmd + H are the Shortcut keys for my KM Macros for English and Hebrew, shown above. Also, make sure you change the Font before you change Keyboards. For some reason, the Shortcut Key for the Font within Office 2016 Mac will not work once you have changed to the Customised keyboard.





Remember, if you are starting any Keyboard with a word in an RTL language, it will automatically justify to the right margin of your document. If you want it to begin a sentence or paragraph that is essentially LTR, like English, just press the LTR button or your Shortcut Key.

No comments:

Post a Comment