Generate a navigation Menu for PowerPoint slides using VBA

Steve de Peijper
Office Productivity
2 min readJan 14, 2023

In this article, I will explain and demonstrate the menu generator for Microsoft PowerPoint. This code provides a number of functions that allow you to generate a navigation menu that will appear on the slides*.

The result looks like this (on top of the slide a navigation menu has been added):

The navigation menu is on top

The below video shows how to use the code:

The video shows how you can use 4 functions:

  • Menu; the function that generates the initial navigation menu,
  • Copy; the function that copies the menu to the other* slides and also highlights the menu item that is currently displayed on the slide.
  • New_font_size; the function that changes the font size of all menu items on all slides.
  • Show_hide_menu_labels; the function that shows or hides the text boxes that contain the text that should be used.

A few words on the inner workings of the code

The menu generator

The code will only generate menu items for slides where there is a textbox named ‘menu’ (as shown in the video). So initially the slides and shapes are iterated to count the number of slides containing a ‘menu label’, see here.

From there a table is created, containing the menu.

The core logic will loop over the slides and per slide loop over the shapes in search for a textbox named ‘menu’. Once found, it will add that text label to the navigation table and also create a link to the slide.

The copy function

The core of the copy function will loop the slides in search of a textbox named ‘Menu’, once found it will paste the navigation menu. From there it will loop the column cells of the navigation menu to find the cell related to that slide. That cell will get a darker background.

Changing the font size of the menu

The core of this function will loop the slides in search of the navigation menu, once found the column cells will be iterated and the font size of the cell be set according to the size that the user was prompted to provide.

Hiding the menu text labels

This function also loops over the slides and shapes in search of the text labels. Once found the visibility will be set according to the to value that the user was prompted to provide.

Conclusion

This concludes this article. I hope it's helpful for you, if so, don’t hesitate to leave some claps! Enjoy the functionality!

--

--

Steve de Peijper
Office Productivity

Background in BI & Advanced Analytics enjoys writing code for various applications like analyzing sporting activities, home automation, and office productivity.