VBA Code Alternative for Switching Fonts

Macros recorded via the user interface can sometimes be glitchy. Using a direct VBA code script ensures a clean, instant transition between Preeti and an English font (like Times New Roman).

1.    Press Alt + F11 to open the VBA Editor.

2.    In the left sidebar, double-click Normal > Microsoft Word Objects > ThisDocument.

3.    Copy and paste the following code into the large text window:

vba

Sub SwitchToPreeti()

    Selection.Font.Name = "Preeti"

    Selection.Font.Size = 14

End Sub

 

Sub SwitchToEnglish()

    Selection.Font.Name = "Times New Roman"

    Selection.Font.Size = 12

End Sub

Use code with caution.

4.    Press Ctrl + S to save and close the VBA window.

 

 

Assigning Keyboard Shortcuts to the VBA Code:

1.    Go to File > Options > Customize Ribbon.

2.    At the bottom, next to Keyboard shortcuts, click Customize....

3.    Scroll down the Categories list on the left and select Macros.

4.    On the right side, select SwitchToPreeti. Click inside the Press new shortcut key box, press Alt + Ctrl + P, and click Assign.

5.    Select SwitchToEnglish, press Alt + Ctrl + E in the shortcut box, and click Assign.

6.    Close the windows.

Now you can seamlessly jump between languages while typing without breaking Nepali text characters.

 

Comments

Popular posts from this blog

Google Input tool offline installer Nepali Google Input tool Nepali Windows XP

Google Input tool full offline download for all languages