I use a New Project workbook whenever I’m starting, wait for it, a new project. The idea is that I always have the same stuff in my projects, so why set it up from scratch. At first, it contained the minimum stuff – stuff that was guaranteed to be in every project. Then I learned that it’s easier to delete stuff than add it, so I included a Toolbar module even though not every project will have a toolbar.
Every module has Option Explicit and a private string constant called msMODULE. MErrorHandler comes straight from PED. Some of the other modules look like this:
Private Const msMODULE As String = “MGlobals”
Public gbDebugMode As Boolean ‘true if debug file exists – used in error handling
Public Const gsAPPNAME As String = “NewProject”
Public Const gsCBTOPLEVEL As String = “TopLevelMenu”
Public Const gsCBTAG1 As String = “AppTag1”
Public Const gsCBTAG2 As String = “AppTag2”
Do you think “NewProject” has shown up on some message boxes? Well, I haven’t forgotten to change it yet, but I’m sure it will happen someday.
Private Const msMODULE As String = “MOpenClose”
Const sSOURCE = “Auto_Open()”
Application.EnableCancelKey = xlErrorHandler
On Error GoTo ErrorHandler
gbDebugMode = Len(Dir(“C:Test_Datadebug.ini”)) > 0 ‘sets the debug mode for error handling
Application.EnableEvents = True
If bCentralErrorHandler(msMODULE, sSOURCE, , True) Then
On Error Resume Next
Application.Calculation = xlCalculationAutomatic
Application.StatusBar = False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.CellDragAndDrop = True
Private Const msMODULE As String = “MVersion”
Public Const lAPPVER As Long = 1
Public Const lAPPBUILD As Long = 1
MToolbar creates a menu item, a command button, and a popup. I’ve never bought into the table driven approach, and I’m not sure why. MToolbar does get a little unwieldy, but once it’s set up, I change it so rarely.
I usually end up adding a module called MProcess that holds the business logic. I don’t like the name but haven’t come up with a better one. Yeah, I know MBusinessLogic.
You can download NewProject.zip. What’s in your new project template?