Friday, 28 June 2019

Building Blocks for Repeatable Text Blacks, with Macros

Found some useful content today on the web today to help me with the creation of Word. I've been looking at various ways on trying to simplify Word document creation and reuse text from other documents I've created. There's some good Python stuff out there that allows you to do it via the browser, but my Python isn't good enough. Lots of searching keeps on bringing me back to the same answer, in the end I keep ending up with Microsoft Word Building Blocks.

I've managed to create to create Building Blocks that include diagrams and tables and use the Building Blocks Organiser (under Quick Parts) to save them as blocks of text. I've used the Gallery and Category options to organise these. I found though it's still a hassle to insert them, so I looked at what options I had.

First off I've created a new Tab in MS Word called 'MyText', my plan was to insert my custom text from there. To do this:

Right click on the Ribbon and select "Customize the Ribbon..."

Select "New Tab" and give it a name (by right clicking on the tab just created)

Select "New Group" from within that Tab, again giving it a name

I then assigned a macro to text blocks, and associated this macro with a button on the new Tab. This means I can select and insert my text blocks. I used the Record Macro option in the Developer Tab to do this. To add a button to my new Tab I went to "Customize the Ribbon..."again but selected Macros in the "Choose commands from:" drop down menu.

Once it appeared in the Tab I changed the name of it to make it more meaningful.

This might get unweildy if I get lots of text blocks, if those I might go back to using the Building Block Organiser, but this is a good start for me. And this might seem a lot of effort, but if I'm going to be doing lots of documents with similar content then it'll be a lot quicker in the long run.

Ideally I'd like to create a UserForm whereby I select the text blocks and it auto-generates the document. That's a work in progress and I need to work on my Visual Basic skills.

With all some pretty pictures and more detail later, but this is just a reminder to myself for later reference...