VBA-tools2 / FixLinks2UDF.vba

Excel AddIn for Fixing Links To UDFs In AddIns.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FixLinks2UDF.vba

Excel AddIn for Fixing Links To UDFs In AddIns.

This is essentially a republish of Jan Karel Pieterse’s article https://jkp-ads.com/articles/FixLinks2UDF.asp. So all credits go to him!

The main reason for this repository is to bundle all improvements at one point. Otherwise one has at least to dig through all the comments below the article to find them. And in the meantime a lot of additional features/functionality has been added.

Features

  • Fix links in Workbooks to UDFs in AddIns which paths have changed (this is the main/original feature)

  • allow fixing links also when the extension of the AddIns have changed

  • allow fixing links also on (passwordless) protected Worksheets

  • allow to have a “wrapper” AddIn (named FixLinks2UDF.xlam)

Prerequisites / Dependencies

Since this is an Excel AddIn you obviously need Microsoft Excel.

How to install / Getting started

ℹ️

If you want to to build the AddIn from source, please have a look at How to create the AddIn from source.

Use distributed FixLinks2UDF AddIn

The simplest way to get started is to

  1. download the FixLinks2UDF.xlam file (from the root folder) and save it to a place of your choice. (The default path for Office AddIns (on Windows) is

    C:\Users\<user name>\AppData\Roaming\Microsoft\AddIns

    which can safely be used.)

  2. Start Excel

  3. Activate the AddIn

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

    2. adding a checkmark at the FixLinks2UDF entry.

There are several options/functionalities to choose from. To check them out please have a look at AddIn options.

Now the FixLinks2UDF AddIn is “listening” and you need to “register” the AddIns, whose UDF links should be fixed. That is done by

  1. opening the Visual Basic Editor (VBE) (Alt+F11),

  2. adding the module FixLinks2UDF_Client.bas to the AddIn of your choice,

    • With Rubberduck:

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

      2. Select the corresponding file in the src folder and click on Open.

    • Without Rubberduck:

      1. Select the corresponding file(s) in the src folder (e.g. in the Windows 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. adding the line,

        FixLinks2UDF_Client.RegisterAddInToFixLinks2UDF

    to the Workbook_Open() event (in the ThisWorkbook class module (which can be found in the “Microsoft Excel Objects”)), and

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

  5. saving the AddIn.

    1. Be sure that the AddIn/project you want to save is “active” in the VBE by checking, if its name is shown in the 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 Explorer.

Ensure right loading order of AddIns

Last you need to make sure that the AddIns (whose links should be fixed) are loaded after the FixLinks2UDF AddIn. This (safely) can be done by

  1. opening Excel’s Add-Ins window (e.g. Developer  Add-ins  Excel Add-ins),

  2. activating the AddIn FixLinks2UDF (it should already be active if you have followed this guide),

  3. deactivating all AddIns which were modified as specified above, i.e. whose links should be fixed,

  4. confirming the selections by pressing the OK button,

  5. closing Excel,

  6. reopening Excel and the Add-Ins window,

  7. activating all AddIns which were modified as specified above, i.e. whose links should be fixed,

  8. confirming the selections by pressing the OK button, and

  9. closing Excel (again).

ℹ️

All the closing and reopening is needed to ensure that it really works. Otherwise there are plenty of pitfalls that can (to the authors experience) easily lead to unexpected results.

💡

If you want to check that there are no obvious errors you can

  • reopen Excel,

  • recheck in the Add-Ins window that the relevant AddIns are checked, and

  • check the Immediate window in the VBE (Ctrl+G) that there are no messages like

    !!! <Workbook name of AddIn>: The AddIn 'FixLinks2UDF' is blocked or isn't found.

Hopefully the stated message is clear enough what might be wrong. For the first cause have a look at the corresponding FAQ entry. For the second cause most likely the FixLinks2UDF AddIn isn’t loaded before the AddIn named in the Immediate window. Redo the steps from the previous list to fix this.

Usage / Show it in action

If you have followed the instructions given in the How to install / Getting started section, possible “old”/outdated links should be updated automatically upon opening a respective Excel file.

In case you want to first see “FixLinks2UDF” in action before modifying our own AddIns, you can have a look at the tests folder. There you will find some test AddIns and a test file. To assure that the test works fine, please check that you first activate the FixLinks2UDF AddIn and then activate the “test” AddIns!

Running Tests

Unfortunately we don’t know how to create automated tests/unit tests for this project. If you have an idea, we would love to see it! Please add an issue or – even better – a pull request (see the Contributing section).

But of course one can manually test it. Please have a look at the tests folder.

Used By

This project is used by (at least) these projects:

If you know more, we will be happy to add them here. In addition it is used by a lot of private, i.e. non-public, Excel AddIns created by the authors.

Known issues and limitations

None that we are aware of.

Contributing

All contributions are highly welcome!!

If you are new to git/GitHub, please have a look at https://github.com/firstcontributions/first-contributions where you will find a lot of useful information for beginners.

We recently were pointed to https://www.conventionalcommits.org which sounds very promising. We will use them from now on too (and hopefully don’t forget it in a hurry).

FAQ

  1. What are the '@... comments good for in the code?

    You should really have a look at the awesome Rubberduck project!

  2. Although the loading order of the AddIns is correct, I (still) get the "!!! …​" message(s) in the Immediate Window. What can I do against it?

    Then most likely the FixLinks2UDF AddIn is blocked by Windows. A quick indicator for that is, that this AddIn isn’t listed in the VBE’s “Code Explorer”/“Project Explorer”. To confirm and fix this suspicion, please have a look at Jan Karel Pieterse’s article: Excel add-ins fail to load

License

MIT

About

Excel AddIn for Fixing Links To UDFs In AddIns.

License:MIT License


Languages

Language:VBA 98.2%Language:Visual Basic 6.0 1.8%