All Visio documents can contain VBA code, but they must be saved with one of the macro-enabled extensions. Often, the best location for custom VBA code is in a stencil, saved with a VSSM extension. This is because it can be easily opened for read-only purposes by multiple documents and users.
This book has companion VBA code in a Visio stencil called
Mastering Data.vssm. The project name,
Mastering_Data, and other values can be set in the Project Properties dialog opened from the Tools menu.
VBA projects can also be locked with a password on the Protection tab of the Project Properties dialog, as shown in the next screenshot: