Skip to content

Instantly share code, notes, and snippets.

@jawn
Last active September 28, 2023 15:48
Show Gist options
  • Save jawn/7a921a8fb59fd97ac743fcf5d0c9bbf1 to your computer and use it in GitHub Desktop.
Save jawn/7a921a8fb59fd97ac743fcf5d0c9bbf1 to your computer and use it in GitHub Desktop.
Making Word Building Blocks Great Again
Word Building Blocks
Documentation:
- https://support.office.com/en-us/article/create-and-use-content-building-blocks-in-word-documents-0b5a27ae-9776-4096-bcfc-98599f16cadc
Defining building blocks:
- Custom building blocks are stored in a Word template.
- Ribbon Insert > Quick Parts > Building Blocks Organizer.
Using a building block:
- Ribbon Insert > Quick Parts > Select from list
The good:
- Building blocks allow you to define and reuse pieces of Word documents
- Preview of what it looks like
- Metadata: you can add a description
- You can group building blocks into Categories
The bad:
- The more building blocks you create, the harder it gets to find the one you are looking for.
What's missing:
- Allow searching the building blocks by name, description
- Collapse/expand building blocks categories
Possible solutions:
- Change Word -> Ask Microsoft
- Create Word add-in/extension
- Old style VSTO add-in (.NET)
- You can use two JavaScript APIs to interact with the objects and metadata in a Word document (https://dev.office.com/reference/add-ins/word/word-add-ins-reference-overview)
Word JavaScript API - Introduced in Office 2016.
JavaScript API for Office (Office.js) - Introduced in Office 2013.
References:
- Macro to insert a Building Block
https://answers.microsoft.com/en-us/office/forum/office_2010-word/macro-to-insert-a-building-block/de3987d2-2065-478b-b6f4-6d38ce6bc279?auth=1
- Create a Custom Building Block Gallery (Word VBA)
https://msdn.microsoft.com/en-us/vba/word-vba/articles/create-a-custom-building-block-gallery
- Experiment with Script Lab to learn the JavaScript API for Office
htps://aka.ms/scriptlab
QUESTION 1: can you list building blocks in a Word Add-In via the JavaScript API?
https://stackoverflow.com/questions/46413020/accessing-building-blocks-in-word-add-in-javascript-api
QUESTION 2: if not, can you do this in another type of Word Add-in (VSTO/...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment