Skip to content

zotero/zotero-word-for-windows-integration

Repository files navigation

Zotero Word for Windows Integration

This is a Zotero extension that consists of a library written in C++ that communicates with Microsoft Word out of process using OLE Automation, a js-ctypes wrapper for said library, and a template that is installed into Microsoft Word to communicate with Zotero.

Development Setup

After cloning, install git hooks:

./scripts/install_hooks.sh

This sets up a pre-commit hook that automatically runs build/template/unpack_templates.sh when install/Zotero.dotm is modified, keeping the unpacked template files in sync.

C++ Library Build Requirements

  • Visual Studio 2022
  • Microsoft Office (previously built with 2010, but newer versions should work)

To Build the C++ Library

  • Open build/zoteroWinWordIntegration/zoteroWinWordIntegration.sln
  • Change imports.h to point to the appropriate files (may be in different places with newer Office)
  • Set to Release configuration in the dropdown in the toolbar
  • Set to Win32 target in dropdown to the right of Release dropdown
  • Build->Build Solution
  • Set to x64 target in dropdown
  • Build->Build Solution
  • Set to ARM64 target in dropdown
  • Build->Build Solution

Template Build Requirements

  • Templates should be built with the oldest version of Word to be supported. Otherwise older versions of Word may fail to function properly.

To Modify/Build the Templates

  • Open the template from inside Microsoft Word
  • Go to View->Macros->View Macros and click "Edit" for one of the Zotero macros
  • Edit/replace code as desired
  • Go to Debug->Compile Project to ensure there are no code errors
  • Run build/template/unpack_templates.sh

Development Starter's Guide

Start by opening the dotm template in Word. Word templates have support for custom macros and adding UI elements to call the macros, which is how the extension is implemented on Word. RibbonUI can be edited by extracting the dotm file or using the Custom UI Editor. In VBA macro code you will find that SendMessage protocol is used to issue commands to Zotero process from Word. These commands are received in commandLineHandler.js where they are passed to integration.js.

Zotero talks to Word via js-ctypes bindings to a C++ OLE Automation based library. To generate new interfaces for Word interop communications you should use the Add New Class wizard in Visual Studio and select 'MFC Class from Typelib'. The interop API docs can be found in the MSDN.

About

Zotero Word for Windows integration

Resources

License

Contributing

Stars

Watchers

Forks

Contributors