Skip to content

VBAToolKit feature : Automatic Export of modules

lucas-v edited this page Sep 11, 2013 · 2 revisions

The automatic export of modules when saving the DEV workbook is a feature of VBAToolKit.

The DEV workbook of a VBAToolKit project is the one embedding all the modules, with a vtkConfigurations configuration sheet listing the different configurations (for more on the subject, Project Configurations in VBAToolKit )

The DEV Workbook is the one where the developer works.

What happens

When saving the DEV workbook, the modules of the DEV configuration will be exported to their respective paths in the vtkConfigurations worksheet.

  • By default, only the modified modules will be exported.

  • Modules that do not have their source yet exported in the path specified in the vtkConfigurations worksheet will be exported, even if they are saved.

How it happens

This behaviour involves event handling and configuration management.

The DEV workbook of a VBAToolKit project embeds in its ThisWorkbook object a Workbook_BeforeSave event handler.

This event handler calls the vtkExportConfiguration function — whose code is in the VBAToolKit.xlam add-in — on the DEV configuration of the vtkConfigurations sheet.

The handler looks like :

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    VBAToolKit.vtkExportConfiguration projectWithModules:=ThisWorkbook.VBProject, _
                                      projectName:="MyProject", _
                                      confName:="MyProject_DEV", _
                                      onlyModified:=True
End Sub

This handler is inserted during the creation of the project, according to the project name chosen by the user.

Later on, the user can modify the parameters given to the function to suit his needs (for example, one might want to change the project name).

About the onlyModified boolean parameter :

  • If onlyModified is set to True, only the modified modules of the configuration will be exported.

  • If onlyModified is set to False, all the modules of the configuration will be exported.

  • As specified in the above section, a module that does not have its source in the path specified in the vtkConfigurations worksheet will be exported whether onlyModified is True or False.

Notes

  • A module not listed in the vtkConfigurations worksheet will not be exported.