Get & Save Settings to the Registry using PowerPoint VBA

If you are writing your own macros and VBA code in PowerPoint, especially if you are creating a PowerPoint add-in, sometimes you might find useful to get and save your settings globally. In Windows, the Registry is a good place to save this kind of settings. Today we will learn how to use PowerPoint and VBA to Get & Save settings to the Windows Registry.

Why may you be interested to save settings to the registry? Here is the motivation. When we created the Export Images add-in for PowerPoint 2010, we wanted to save the user selected destination output folder as a setting, so next time the plugin is used we will get (load) the setting from the Windows Registry. Easily we will save lot of time by getting the default output folder.

Sub GetSaveSettings()
    Dim path As String
    path = GetSetting("FPPT", "Export", "Default Path")
    SaveSetting "FPPT", "Export", "Default Path", path
End Sub

This code will use GetSetting to get the default path from the Windows Registry and immediately after will save the same setting.

How have we used this save setting feature for our free templates for PowerPoint? When we created our VBA plugin for PowerPoint to export images from the active presentation, we needed a quick way to locate the output folder easily. As you can guess from the snippet code above, we loaded the registry setting Default Path to display it in the FileDialog before the images are exported to the destination folder. If we chose a different path then we save it for future use.

 

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Leave a Comment

Your email address will not be published. Required fields are marked *