Backstage and profiles

A settings page in the File menu, with several profiles.

The backstage is the page Excel shows when you click File. Your add-in can put its own settings page there.

What it is for

Everything your add-in needs to know but should not ask on every click: a path, a client, an identifier, a switch. You define fields, the user fills them in, your VBA reads them.

Profiles

The same fields can be filled several times over. Someone working for three clients keeps three profiles and switches, instead of retyping everything.

Optionally the switch also appears as a drop-down in the ribbon, so it does not have to go through the File menu.

Where the values live

In a file settings.json in that user's profile, under %APPDATA%\<folder name>, on that machine. None of it leaves the workstation, and none of it is in the .xlam. So the file is identical for everyone while the settings stay personal.

You set the folder name in the editor, and it applies as you type it, including characters such as “ř” or Cyrillic letters. The export only changes what Windows cannot create as a folder name: trailing spaces and dots are dropped, control characters become _, and device names get a _ (CON becomes CON_, NUL.txt becomes NUL_.txt). The hint in the editor shows the folder the add-in actually uses.

If the file cannot be written (because the folder is read-only, say), the add-in reports it with the file's path, and the profile keeps its * for unsaved changes. The values then apply until Excel is closed.

Reading them from VBA

The generator writes procedures that read a field's value from the active profile. Which ones exactly is visible in the generated module, which you can open in the VBE.

A field's key becomes its name in VBA (p.DatevPfad). So it consists of letters, digits and underscore, starts with a letter, is not a VBA word such as Name or Date, and occurs only once regardless of case (Client and client are the same name to VBA). While a typed key does not meet that, a hint shows below the field and the previous key stays saved. A default value has at most 256 characters and may contain any character, including ones the VBA editor itself cannot show (such as “ř” or “✓”); they reach the add-in unchanged.

Templates

Five ready-made field sets are available, for a tax practice, controlling or sales among others. They are a starting point, not a corset: take one, rename, extend.