Mel Starrs has just posted a handy time-saving tip over at Elemental which explains how to use MS Word’s autocorrect feature to ensure that your CO2 subscript always comes out right. It’s a handy approach and saves your work from the annoying critic who ignores your carefully crafted argument while pointing out every last formatting error.

My contribution here is from the point of view of someone who edits quite a lot of other people’s reports as well as writing my own, in which case you can’t rely on the autocorrect method. Instead I hunted around on the net for a way of correcting it automatically using a macro. Eventually I found what I was looking for on G Mayor’s site . It needed a bit of adaptation to do exactly what I wanted but it’s now a real time saver. It covers:

  • m2
  • m3
  • R2
  • CO2
  • NO2
  • SO2
  • H2O

Just download and unzip the file from the link below, then import it to your Normal template in MS Word.

FormatFormulae.

To add the macro to the Normal template open up MS Word and press Alt-F11 to open the VBA editor window —>  Ctrl-R to show the project explorer (if it isn’t already showing) —> right click the Normal template —> Import file —> browse for the FormatFormulae.bas file —> Open, and you’re done.

It’s so handy that I also decided to add it to the Quick access bar for easy access (MS Word 2007 and 2010 only).

To add a button to the Quick Access Toolbar in MS Word 2010, first click on the down arrow at the right hand end of the row of icons that includes the Save icon, then select More commands —> Choose commands from —> Macros. Then find Normal.FormatFormulae.CommonFormulae in the list that appears and use the Add >> button to move it across to the Quick Access Toolbar.

Next you can add an icon so you can find it easily. I’ve hijacked the π symbol which normally serves as the insert formula button but you can add whatever makes sense to you. Just click Modify and select an icon from the options that appear.

If you’re confident messing about with VBA for Word, the code is commented to show you how to adapt it to cover any other subscript/superscript formulae that you use regularly.

Edit: A macro which does the same kind of thing, plus fixes some common typos (KWh for kWh, etc.) for Excel is now available here.

Tags:

Jamie Bull | jamiebull1@gmail.com

Related Posts

WiGLE is a popular platform which can be used for finding the location of a device using the names of WiFi networks in its vicinity. I’ve written about this before, and wrote some Python code to interact with their API. This API has since been retired and replaced with a new one, as of December […]

Just a quick post to point out a couple of really useful tools. The first is a web-based tool for finding weather files for a location of interest. It’s similar to the Excel EPW finder tool we created a few years back, but much more modern looking. It is however missing a few of the […]

Eppy is a really useful library which I’ve written about several times, since before I really had anything to offer in terms of contributing code. Over the past year or so though, I’ve started to contribute back some of the changes and additions I’ve made while using eppy on academic and commercial projects. This post […]

Leave a Reply

Your email address will not be published. Required fields are marked *