Skip to content

Latest commit

 

History

History
98 lines (92 loc) · 6.61 KB

AddIn_create.adoc

File metadata and controls

98 lines (92 loc) · 6.61 KB

How to create the AddIn from source

You have two choices to make the functionality work, i.e. to fix the links to UDFs in AddIns. Either you create a “wrapper” AddIn named FixLinks2UDF.xlam that handles the fixes or you use the code “stand-alone” which means that you add the code to each AddIn which UDFs links should be fixed. The former has the benefit that you only have one place to incorporate fixes and/or new features.

“Wrapper” AddIn

  1. Open a fresh/new Excel file.

  2. Open the Visual Basic Editor (VBE) (Alt+F11).

  3. Add the modules and class modules in the src folder (without the files from the Client subfolder) to the project.

    • With Rubberduck:

      1. Right-click on the project to which you want to add the modules in the “Code Explorer” (to show it press Ctrl+R) and click on Add  Existing Files…​.

      2. Select all files in the src folder and click on Open.

    • Without Rubberduck:

      1. Select all files in the src folder except ThisWorkbook.doccls in Windows File Explorer.

      2. Drag-and-drop them to the corresponding project in VBE’s “Project Explorer”.
        (To show it press Ctrl+R. Hit it twice if the Code Explorer shows up first.)

      3. Open ThisWorkbook.doccls in an editor, copy its content, and paste it to the ThisWorkbook class module (which can be found in the “Microsoft Excel Objects”).

  4. Add a reference to the “Microsoft Scripting Runtime” library.

    • With Rubberduck:

      1. Right-click somewhere on the project in the Code Explorer and click on Add/Remove References…​.

      2. Type (parts of) the library name in the search box until you see it in below (left) list.

      3. Select the library in the (left) list and click on the button to add it to the project references.

      4. Click on the OK button to close the window.

    • Without Rubberduck:

      1. Open the Reference manager in the VBE (Tools  References…​).

      2. Add a checkmark to the corresponding library.

      3. Click on the OK button to close the window.

  5. Change project name to FixLinks2UDF

    • With Rubberduck:

      1. Right-click on the project to which you added the modules in the Code Explorer,

      2. click on Project Properties, and

      3. change the “Project Name” accordingly.

    • Without Rubberduck:

      1. Right-click on the project to which you added the modules in the VBE Project Explorer,

      2. click on VBAProject Properties…​, and

      3. change the “Project Name” accordingly.

  6. Check, if there are obvious errors by compiling the project (Debug  Compile FixLinks2UDF).

  7. Save the file/project as FixLinks2UDF.xlam.

    1. In Excel (not the VBE) press the Save button (e.g. in the Quick Access Toolbar),

    2. change the “Save as type” value to “Excel Add-in (*.xlam)”,

    3. change the “File name” accordingly, and

    4. save it in a location of your choice by pressing the Save button. (It is perfectly fine to use the folder that is suggested/shown by Excel when you change the “Save as type” value.)

  8. Close Excel

  9. Activate the AddIn

    1. by opening Excel,

    2. opening the Add-Ins window (e.g. Developer  Add-ins  Excel Add-ins), and

    3. adding a checkmark at the FixLinks2UDF entry.

  10. Run the sub SetDocumentProperties in the modDocumentProperties module.

    1. Open the VBE (Alt+F11),

    2. open the module modDocumentProperties (via Code Explorer or Project Explorer),

    3. place the cursor somewhere in the procedure SetDocumentProperties, and

    4. run that sub (e.g. by pressing F5).

“Standalone” AddIn

  1. Open the VBA project, to which you want to add the FixLinks2UDF functionality in the Visual Basic Editor (VBE) (Alt+F11).

  2. Add the modules and class modules in the src folder except the ThisWorkbook.doccls to the project.

    • With Rubberduck:

      1. Right-click on the project to which you want to add the modules in the “Code Explorer” (to show it press Ctrl+R) and click on Sync Project  Update Components from Files…​.

      2. Select all files in the src folder except the ThisWorkbook.doccls and click on Open.

      3. Open ThisWorkbook.doccls in an editor and merge its content with the (maybe present) content of ThisWorkbook class module.

    • Without Rubberduck:

      1. Select all files in the src folder except ThisWorkbook.doccls and drag-and-drop it to the corresponding project in VBE’s Project Explorer.

      2. Open ThisWorkbook.doccls in an editor and merge its content with the (maybe present) content of ThisWorkbook class module (which can be found in the “Microsoft Excel Objects”).

  3. Add a reference to the “Microsoft Scripting Runtime” library.

    • With Rubberduck:

      1. Right-click somewhere on the project in the Code Explorer and click on Add/Remove References…​.

      2. Type (parts of) the library name in the search box until you see it in below (left) list.

      3. Select the library in the (left) list and click on the button to add it to the project references.

      4. Click on the OK button to close the window.

    • Without Rubberduck:

      1. Open the Reference manager in the VBE (Tools  References…​).

      2. Add a checkmark to the corresponding library.

      3. Click on the OK button to close the window.

  4. Check, if there are obvious errors by compiling the project (Debug  Compile ‹project name›).

  5. Save the AddIn/project.

    1. Be sure that the AddIn/project you want to save is “active” in the VBE by checking, if its name is shown in VBE’s title bar.
      (If it’s not, open a (class) module of the corresponding AddIn (and close it again).)

    2. Press the “Save” button (the disc symbol similar to 💾) in VBE’s toolbar.

    3. Check that the file (really) was saved by having a look at the “last modified date” of the AddIn file in the Windows File Explorer.

  6. Close Excel