Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (63 sloc) 2.8 KB
Attribute VB_Name = "bootstrap"
Option Explicit
' This file is part of the Minnesota Population Center's VBA libraries project.
' For copyright and licensing information, see the NOTICE and LICENSE files
' in this project's top-level directory, and also on-line at:
Public Const MODULE_FILENAME = "bootstrap.bas"
Public Enum ToolkitMode
Unknown = 0 ' So an uninitialized variable will have this value
End Enum
' The mode that the add-in is currently running in.
Public CurrentMode As ToolkitMode
Public Enum ToolkitEdition
Unknown = 0 ' So an uninitialized variable will have this value
Development ' (toolkit base name)_DEV.xlam
BuiltProduction ' (toolkit base name)_PROD.xlam
InstalledProduction ' (toolkit base name).xlam
End Enum
' The current edition that the add-in represents
Public CurrentEdition As ToolkitEdition
' The name and file path for the configuration and loader modules that
' are imported in Development mode.
Public ConfModule_Name As String
Public ConfModule_Path As String
Public LoaderModule_Name As String
Public LoaderModule_Path As String
' This module is NOT imported into the development version of the add-in.
' It is exported to MODULE_FILENAME so a copy of its code is under version
' control. Changes to its code must be made in the Visual Basic editor. To
' make those changes, the development add-in must be opened with
' macros disabled. That will allow the add-in to be saved with just this
' bootstrap module.
' Called by ThisWorkbook.Workbook_Open event procedure (as a workaround
' for this issue:
Public Sub InitializeAddIn()
If ThisWorkbook.Name Like "*NO-LOAD*" Then
' Do not import any modules so developer can change file properties.
Exit Sub
End If
If ThisWorkbook.Name Like "*DEV*" Then
CurrentMode = ToolkitMode.Development
CurrentEdition = ToolkitEdition.Development
ConfModule_Path = Replace(ThisWorkbook.FullName, "DEV.xlam", _
LoaderModule_Path = ThisWorkbook.Path & Application.PathSeparator _
& "loader.bas"
With ThisWorkbook.VBProject.VBComponents
ConfModule_Name = .Import(ConfModule_Path).Name
LoaderModule_Name = .Import(LoaderModule_Path).Name
End With
Application.Run "loader.LoadToolkitModules"
CurrentMode = ToolkitMode.Production
If ThisWorkbook.Name Like "*PROD*" Then
CurrentEdition = ToolkitEdition.BuiltProduction
CurrentEdition = ToolkitEdition.InstalledProduction
End If
End If
Application.Run "toolkit.Initialize"
End Sub