In this post:

Private Profile files made easy and transparent.

Appropriateness

Microsoft suggests to use the Registry instead of Private Profile files. A Private Profile file may still worth being considered because:

  • Anything written to the registry by a VB-Project is personal and not available for other users but a Workbook/VB-Project may be used by multiple individuals which should make use of the same configuration.
  • When the VB-Project has been developed by a professional contractor the configuration should no be an integrated part of the implementation. Any modified VB-Project will then use the client’s configuration. And last but not least may the contractor’s configuration differ from the client’s.
  • A “common” Workbook/VB-Project may be used by different clients, each with an individual configurations.

Implementation

There are a couple of library calls available for the maintenance of a Private Profile file. Their interface is somewhat unusual and has some limitations however. An easy going implementation (at least from my point of view) would be a Class Module with a Value Get and a Value Let Property with the three parameters:

  • file_full_name
  • section_name
  • value_name
  • value_default (used for Value Get only, value returned as default when not available)

For comprehensiveness there are a couple of other methods and properties thinkable.

An example

The autonomous Class Module clsPrivProf may be downloaded (see how to when unfamiliar with GitHub) and imported from the public GitHub repository or the code may directly be copied into a Class Module named clsProvProf. The module runs without any specific library calls and provides the following advantages:

  • An unlimited string length (no hassle with buffer size)
  • Sections and Value-Names are maintained in ascending order
  • Optional comment lines (file header, file footer, section comment, and value comment)
  • Sections are separated by an empty line
  • Easy to use methods and properties since all use the same set of three parameters.

Usage

  • Value write: Value(<value-name>[, <section-name>][, file-full_name]) = "any"
  • Value read: result = Value(<value-name>[, <section-name>][, <file-full-name>])
    • value_name (obligatory)
    • section_name (optional)
    • file_full_name (optional) Note: Both, the section-name and the file-name are optional. Specifically the file_full_name will usually be omitted since specified once when the class instance is established.

For further information see the corresponding README and a supplementing SpecsAndUse document.

Download from GitHbub

For those unfamiliar or discomfort with GitHub: The link displays the module’s Export file which allows to download it or copy the code
downloaded
downloaded or imported