Microsoft Office Tutorials and References
In Depth Information
What Makes a Good Utility?
Figure 16-5 shows these settings in the Windows Registry Editor program ( regedit.exe ).
Figure 16-5: Use the Windows Registry Editor program to view the settings stored in the Registry.
If you examine the code for the Text Tools utility, you’ll find that I used an eight-element array
(named UserChoices ) to store the settings. I could have used separate variables for each
setting, but using an array made the coding a bit easier.
The following VBA code reads the settings from the Registry and stores them in the
UserChoices array:
‘ Get previous settings
UserChoices(1) = GetSetting(APPNAME, “Settings”, “OperationIndex”, 0)
UserChoices(2) = GetSetting(APPNAME, “Settings”, “ChangeCaseIndex”, 0)
UserChoices(3) = GetSetting(APPNAME, “Settings”, “TextToAdd”, “”)
UserChoices(4) = GetSetting(APPNAME, “Settings”, “AddTextIndex”, 0)
UserChoices(5) = GetSetting(APPNAME, “Settings”, “CharsToRemoveIndex”, 0)
UserChoices(6) = GetSetting(APPNAME, “Settings”, “RemovePositionIndex”, 0)
UserChoices(7) = GetSetting(APPNAME, “Settings”, “RemoveSpacesIndex”, 0)
UserChoices(8) = GetSetting(APPNAME, “Settings”, “RemoveCharactersIndex”, 0)
cbSkipNonText.Value = GetSetting(APPNAME, “cbSkipNonText”, 0)
The code that follows is executed when the dialog box is closed. These statements retrieve the
values from the UserChoices array and write them to the Registry.
‘ Store settings
SaveSetting APPNAME, “Settings”, “OperationIndex”, UserChoices(1)
SaveSetting APPNAME, “Settings”, “ChangeCaseIndex”, UserChoices(2)
SaveSetting APPNAME, “Settings”, “TextToAdd”, UserChoices(3)
SaveSetting APPNAME, “Settings”, “AddTextIndex”, UserChoices(4)
SaveSetting APPNAME, “Settings”, “CharsToRemoveIndex”, UserChoices(5)
SaveSetting APPNAME, “Settings”, “RemovePositionIndex”, UserChoices(6)
Search JabSto ::

Custom Search