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?
Add-Ins
in the word add-ins
there is no option for .wll
for some reason.Updated Answer (after some more experiments).
The summary: As far as I can tell, a WLL that functions correctly on Word 2013 does not function on the current version of Windows desktop Word in Office 365, even with the Trust Center "Enable all macros" option checked.
A bit more: If I put a 32-bit and a 64-bit version of a .WLL that works on Word 2013 into the STARTUP folder in a Windows desktop WOrd from Office 365, Word does not load either .wll at all, i.e. they do not even appear in the relevant box in the Templates and add-ins dialog in the Developer tab. (IN previous versions of Word, a .wll with a working DllMAin entry point would at least list the .wll in that box, but not as loaded (i.e. its checkbox is unchecked).
If I try to load them from that dialog box, I see the error message "The document template is not valid."
That said, there are two problems with your code (not just the one I mentioned before:-
The entry point names for the two routines should start with wd
, not wl
the "AutoClose" needs to be "AutoRemove"
i.e. the two routines should be called wdAutoOpen and wdAutoRemove
So you might want to change those and re-check for yourself.
Background:
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 tag here in SO.
Here, I tested using Word 2410 (Build 18129.20116 Click-to-run, Preview channel) on Windows 10 and Word 2411, Buld 18227.20046 Click-to-run, Preview channel (I think that's one of the Insider options) on Windows 11. that said, even if Microsoft has closed a security loophole in this area since Word 2016 was released, I don't know when they did it and whether it would also affect one-time purchase versions of Office 2016 and so on.
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.
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.