Configuration GUI and move to Windows Registry

I’ve been wading my way through a few VBA websites trying to fathom out the best/quickest/easiest ways to store settings in the Windows Registry.  I’ve now done a few bits of test code and I’m about 50% of the way through storing every setting in there.  Once this is done I can remove the code that looks at the old .INI file.

The reason is two-fold.  The main reason is that the .INI file was going to get more and more data stored in it due to some planned new functions.  The secondary reason is that should anyone want to attempt a Mac port of the add-in, the same VBA keywords that are used to write to the registry under Windows are also present in the Mac version of Office VBA. They write to a different part of that OS, naturally.

The other change is re: a proper GUI to handle the configuration.


The drop-down at the top will allow you to change the different configuration areas: Properties Report locations, Template locations and the Ignored Folders list.  You can also change the text that appears in the Company Name area of the ‘Fix Footer’ function.

The Add, Save and Delete buttons currently have no code behind them, but it’s not bad for an afternoon in VBA 🙂

Reworking the Delete ^p^p function

All I wanted to do was to update this function to work with a selection (i.e. user has made a selection of text, which included a few multiples of ^p in it) and the search & replace would then only work in that area.  If there was no selection made, then the function would assume you wanted to work with the whole document.  Seemed easy enough at first …

… then I got into the various difficulties that automating Word’s Search & Replace via VBA causes.

In the end, and to help my own sanity, a post in the Word VBA group I frequent on LinkedIn came up with a solution to my problem.

It turns out that if you want to remove the duplicate ^p^p from a selection, you need to search for ^p^p and you must remember to switch wildcards off (as you’re only looking once through a selection). However, the opposite is true if you are looking to do a whole search and replace through a whole document, then you need to replace this with ^13^13 instead.

Or, at least, that’s I got it working in the end.