For the past couple of weeks, I have been developing Microsoft Word Add-in's using theOffice.js framework, which lets you create web applications that can interact directly with any Microsoft Office application.
One of the tasks that has taken me the most time so far has been understanding and debugging themanifest.xml
file, which is the file where UI components like labels and menus that integrate into the context menu (that box you get when you right-click) or the ribbon (the row of buttons at the top) are defined.
Debugging amanifest.xml
file can mean two things. We will cover them both here.
1. Determining if it is valid XML for an Office Add-in
Microsoft provides a tool to check whether yourmanifest.xml
is valid. You can read about it inmore detail here, but the basics are below.
If you used the Yeoman generator
If you used the Microsoft provided generator to set up the Office Add-in, it is as simple as running the command below:
npm run validate
If you did not use the Yeoman generator
You need to take the extra step of installingthe validation package first.
npm install -g office-addin-manifestnpm run validate
This step is well covered in the Microsoft documentation and is mostly here for completeness. But it does not actually report runtime errors, the kind of errors that otherwise silently occur and lead to menus, icons, and buttons not showing up.
2. Determining what errors might be causing it not to render properly
Unfortunately, when you Google for ways to debug the manifest file, it usually points you to theaforementioned validator, which is helpful but does not come close to solving actual bugs in the manifest that might cause your desired UI components to just not appear. It took me several days to figure out how you debug a syntactically correct but broken manifest file, which was a motivation for writing this post.
This debugging methof generates a runtime log for themanifest.xml
of the errors that it encountered:
- Openthe Registry Editor on Windows. You can just search for it in the search bar and the logo looks like that.
- Navigate to
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Wef\Developer\
. - Add a key called
RuntimeLogging
toDeveloper
. To do that, just right click on theDeveloper
folder and chooseNew
and thenKey
. - Click on
RuntimeLogging
and then double click on (Default) in the box to the right. - Add the path to the .txt file where you want the log messages to be written. If you have not created a file for that, go and create one. That path should include the file name.
- Run the Add-in however you normally would in your development environment. As far as I know, it requires no special flags or parameters in any configuration.
- After the Add-in has loaded in Office, you can check the designated file for any useful log messages.
Happy debugging!
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse