VBA – Show all available fonts in MS Word

We know that VBA is also available in MS Word. Very few people use it, and they do it for a reason. Whenever you say that you are an Excel programmer, the “Hard Core” programmers kindly laugh at you and thus I cannot imagine what would happen, if you state you are a MS Word programmer.

Fonts

 

Anyway, it is possible to program in MS Word and it is even more difficult to find a job as a MS Word programmer than it is with any other programming language! 100% sure 😉

In the current example I will show you a code, that shows all the available fonts you have in MS Word and writes them on a word document. Quite a useful thing, if you want to check all the fonts and you do not like the idea of the Word dropdown menu. Anyway, this is what we do with the code:

  1. We generate a table in the active document with 4 columns.
  2. We write on the table “Font Name” and “Example” twice.
  3. We simply write in two columns all the fonts we have, using a boolean variable, telling us whether we should write in the left column or in the right one. If we write in the right one, we need to add a new row.
  4. Pretty much that is it – the for each loop does it all!

Here is the code! Enjoy it with care 🙂

🙂