c++dllms-wordms-officeadd-in

Developing a word library add-in for office 2024


i'am trying to develop addin for word 2024.

I have created a dummy dll like this:

#include <Windows.h>

extern "C" int WINAPI wlAutoOpen(void);
extern "C" int WINAPI wlAutoClose(void);

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReason, LPVOID lpReserved)
{
    if(ulReason == DLL_PROCESS_ATTACH)
        MessageBoxA(0, "from addin", 0, 0);
    return TRUE;
}
int WINAPI wlAutoOpen(void)
{
    return MessageBoxA(0, "test open", 0, 0);
}
int WINAPI wlAutoClose(void)
{
    return MessageBoxA(0, "test close", 0, 0);
}

and a def file:

LIBRARY wlTest
EXPORTS
  wlAutoOpen
  wlAutoClose

I have made a x86/x64 builds ( tried both ) renamed to test.wll copied to: C:\Users\Administrator\AppData\Roaming\Microsoft\Word\STARTUP

Then i started word, but i get no messagebox on startup or when i open/close any word doc. Can someone push me in the right direction?

  1. Do .wll add-in work in word 2024
  2. If so, what is the correct way to install them? There is a menu Add-Ins in the word add-ins there is no option for .wll for some reason.

Solution

  • This is not a definitive answer but it's too long for a comment.

    The "WLL" type of Word Addin is the oldest type of Word Addin and was in effect superseded by "Templates/Wizards with VBA code" and "COM Addins" either when Word 97 or Word 2000 arrived. Since then the VSTO type of addin arrived, followed by office-js, which is the addin technology that Microsoft has been promoting for a long time now.

    So developing a .wll is probably not the way to make an addin even if you can get it function! But there were quite widely used addins, (e.g. maybe MathType?) that relied on .wlls long after 2000.

    So IMO the only really good reason to create a .wll these days is to ensure that the security problem they created has gone. For that, you may be better off asking in a security-oriented forum or trying to find a suitable tage here in SO.

    Personally I have never managed to work out exactly how to make a working .wll, even using very old versions of VC++ and old versions of word. That is, I have never managed to get code in wdAutoOpen to run. That's probably because I don't know C/C++ and the VC(++) dev. environment anything like well enough. Perhaps someone else here does. Incidentally, I think the other routine that Word may call is wdAutoRemove, not wdAutoClose.

    That said, the MessageBoxA call in the DllMain call did work until Word 2013, at least if you set the security settings in Word to the least secure setting.

    Here, I only have the current 365 version of Word (64) bit on Windows 10 and 11. If I try to load the same 32-bit .wll that functioned on Word 2013 I just see an error message "The document template is not valid." I recompiled for 64-bits, and although I have no way of testing the 64-bit version on anything exceept the current version of Word, that resulted in the same error. So I would guess that Microsoft have removed that particular security risk now. Incidentally, on Word 2013 in one of the options that you could choose when you Add a template in the Templaes and Addins dialog, .wll files were listed under Word templates or some such. In the currnt version of Word, you have to choose the "Any Files" option to see them.