Chapter 21. Creating and Removing Applications

Chapter 21. Creating and Removing Applications

Using the add-in, you work with high-level methods while the add-in loads configurations from a database.

So, you may create applications completely using VBA from empty workbooks like in this book.

' Creates the application worksheets, Chapter 21

Sub Chapter21_1_CreateApplication()

    Call Chapter02_2_CreateMasterTableEditors()
    Call Chapter05_1_CreatePaymentsWorksheet()
    Call Chapter06_1_SetPaymentsWhereParameters()
    Call Chapter07_1_SetLanguage()
    Call Chapter09_1_CreateTableViews()
    Call Chapter11_1_CreateReportsWorksheet()
    Call Chapter13_1_ChangeQueryObject()
    Call Chapter14_1_SaveChanges()
    Call Chapter15_1_AddCursors()
    Call Chapter15_2_AddCursorButtons()
    Call Chapter16_1_AddFormFields()
    Call Chapter17_1_CreateCompanyPaymentsWorksheet()

End Sub

When you remove an application, remove the add-in data sheets using the last three methods:

' Removes the application worksheets, Chapter 21

Sub Chapter21_2_RemoveApplication()

    If Not MsgBox("Are you sure to delete all worksheets?", vbYesNo) = vbYes Then Exit Sub

    Dim wb As Workbook
    Set wb = ActiveWorkbook

    Call DeleteWorksheet(wb, "CompanyPayments")
    Call DeleteWorksheet(wb, "Reports")
    Call DeleteWorksheet(wb, "Payments")
    Call DeleteWorksheet(wb, "Accounts")
    Call DeleteWorksheet(wb, "Companies")
    Call DeleteWorksheet(wb, "Items")

    Dim addIn As Object
    Set addIn = GetAddInAndCheck()

    If addIn Is Nothing Then Exit Sub

    Call addIn.DeleteAllTableViews(wb)
    Call addIn.DeleteAllTableCursors(wb)
    Call addIn.DeleteAddInSheets(wb)

    ' The workbook must contain the start sheet only

End Sub