Tag: Word

Resize all images in a Word document with #vbs #macro

TLDR Quick and dirty macro to resize all images in a word document to 145 mm. I am lazy like that. Get the gist of it here. The “Why” Ok, so. I am a consultant, as you may know. And as a consultant, people pay me to do stuff and expect me to be efficient and deliver with high quality. Part of that entails writing documentation containing how I do stuff, where I do it and often why I do it. This documentation is expected to be detailed enough to make sure my customers will be able to follow the steps and produce a copy of my work. Most of the time these document are a big part of the disaster recovery processes and might have to be executed by the on-call staff with no previous knowledge of the product. This means screenshots. Lots of screenshots. And while templates are nice and help me out a lot, the screenshots have to be from the actual installation and not some copy-pasta from a previous assignment. To help me out, I use the excellent free program Greenshot to quickly generate screenshots into a WIP-folder (or directly into Word if that is appropriate) and that makes it possible to grab snapshots of the process without having to pause all the time to PrtScn-Alt+Tab-Ctrl+V-Crop-Ctrl+C-Alt+Tab-Ctrl+C. I simply press PrtScn and go on with the installation. Being a bit pedantic, doesn’t help me out here though as I find myself selecting and resizing all the images in the Word document I have produced. This is a very time-consuming process and not the most exact one either. I want all images to be of scaled, if necessary, to an equal maximum width that fits comfortably withing the margins of the document template my company has prepared for me. So I created a fairly simple macro to do it for me. The “How” If you are un-familiar with macros in Word, you will find them under the “View” tab. Clicking on “Macros” will give you the option to execute the ones you have, or you can create your own using VBA (Visual Basic for Applications). To create one, select where you want it saved (normal.dotx in my case, as I want it readily available) and enter a name for it. This will bring up the Visual Basic for Applications IDE, where you can write your own fun stuff.