Perform simple math in a Word document

I have a MS document that i use as a chain-of custody and analytical results report for air samples. I would like for the document to calculate total minutes from my start and stop time data entry fields as well as calculate total volume from the total minutes and liters per minute field boxes. If I can get that far, I would also like to have the document automatically calculate my final sample results using the following equation: total fibers/ total fields total volume x 7.85 I have separate text fields I use to enter the total fibers count as well as another text field I use for total fields.

27.6k 61 61 gold badges 79 79 silver badges 123 123 bronze badges asked May 14, 2016 at 18:10 James Estes James Estes 31 1 1 silver badge 2 2 bronze badges You can do basic math inside a table. Commented May 14, 2016 at 18:41

Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.

Commented May 14, 2016 at 19:21 There is an answered example of a similar kind of problem at stackoverflow.com/questions/21335920/… – user181946 Commented May 28, 2016 at 15:53

2 Answers 2

You can do formulas in Word.

CTRL+F9 will let you add a FIELD in Word in which you can type several expressions, ant ALT+F9 will show/hide all the fields in the document. You can add FIELDS inside fields themselves to build complex expressions. Fields are shown with curly brackets and each curly bracket group should be added using CTRL+F9 (or a copy/paste from another expression).

Here are some examples to get an idea:

> \@ "d MMMM yyyy">>

The first sets a value, the second displays a computed date, the third should correspond to an expression required in the question with "TotalVolume" already defined as a Bookmark for instance. (Remember to not type the curly braces, get them using CTRL+F9).

Any of the "variables" should be either defined using a "SET" or as a Bookmark in your document.

This feature is not used a lot, so it's not easy to find a good tutorial. A good start to learn how to use this is Microsoft's documentation. You can start with Field code - SET - it has examples futher down in its explication. You can go from there and see for instance that you can have word request data by using the FIELD CODE "FILLIN". While reading that extract, I've learned that CTRL+F9 is available through the menus from the Insert toolbar / Quick Parts / Field which may also help you to start discovering this functionnality.