add a commonly-used table

I watched my colleague Alun Dear laboriously make a bond energy table from scratch, with column headings centralised in bold but the bonds justified left. I realised that every time he made a table for one of his wonderful resources he had to go through the same process every time. ‘Why don’t you just save your table in Building Blocks like this?’ I asked. ‘As long as you can remember what you called your table, all you have to do is type its name then press F3 and the name changes to the table, formatted and complete with all the bond energies. Do the same for electrode potential, subatomic particles, etc. You can have any table you want at the click of a button.’ Building Blocks can also be used to quickly add text or diagrams or any combination of text, diagrams and tables as described here.

(Use the macro here to make a nice electrode potential table. All of the equilibrium signs are underneath each other since they are in their own invisible column without borders.)

  1. Select the entire table:

2.    Press Alt+F3 (or Alt+Fn+F3). Word displays the Create New Building Block dialog box:

3.    Replace the contents of the Name field with the name you want to use for your table.

4.    Click on OK.

5. When you later want to use the table, simply type the name you specified in step 3 and press the F3 key (or Fn+F3).  The table will be inserted in the place of the table name.

change the format of a question to AQA-style

Here at Southampton Exam Factory we do AQA at GCSE. The style of questions is that the marks for a question are at the end of the question, not the student’s answer, and the students write on solid lines:

We take questions from other exam boards and modify them to make them fit our syllabus. Usually the questions have dotted lines for the student’s answer and have the marks available at the end of the student’s answer:

The macro below will replace all dotted lines with solid lines and move the [2] at the end of the answer to a [2 marks] at the end of the question. This makes it much quicker to produce good resources for the students.

Sub ReplaceDottedLinesWithSolidLines()


 'replace question numbers with line
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "\[2\]"
        .Replacement.Text = _
            "[2 marks] __________________________________________________________________________"
                
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    
         Selection.Find.Execute Replace:=wdReplaceAll
         
   'replace question numbers with line
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "\[1\]"
        .Replacement.Text = _
            "[1 mark] __________________________________________________________________________"
                
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    
         Selection.Find.Execute Replace:=wdReplaceAll
          
    'replace question numbers with line
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "\[3\]"
        .Replacement.Text = _
            "[3 marks] __________________________________________________________________________"
                
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    
         Selection.Find.Execute Replace:=wdReplaceAll
          
    'replace question numbers with line
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "\[4\]"
        .Replacement.Text = _
            "[4 marks] __________________________________________________________________________"
                
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    
         Selection.Find.Execute Replace:=wdReplaceAll
    
    
    'align right
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.ParagraphFormat
        .SpaceBeforeAuto = False
        .SpaceAfterAuto = False
        .Alignment = wdAlignParagraphRight
    End With
       
  'remove dots
   'Selection.WholeStory
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Copy
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ".."
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    
    'remove autocorrected dots
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Copy
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "…"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    'remove single dot before question marks
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ". \["
        .Replacement.Text = "["
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ". \["
        .Replacement.Text = "["
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    

End Sub

add powers to a maths equation no.2

The macro below will produce the powers in a maths equation by making the powers size 8 and raising them by 2 points. To do this, put a ‘z’ in front of anything you want to be a power. For anything that you want to be a subscript put a ‘q’ in front of it and it will be lowered by 2 points and made size 8. So to make the following equation:

first insert a fraction from Insert>Equation:

then type (pSOq3)z2 on the top line and (pSOq2)z2 (pOq2) on the bottom line. Then run the macro below. It will also change Cambria Math (sic) font to Arial and get rid of the italics.

Sub MathsEquationsRaisePowersWithZ()

 Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Size = 8
        .Superscript = False
        .Subscript = False
        .Position = 1
    End With
    With Selection.Find
        .Text = "([z])([-])"
        .Replacement.Text = "\2"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Size = 8
        .Superscript = False
        .Subscript = False
        .Position = 2
    End With
    With Selection.Find
        .Text = "([z])([0-9])"
        .Replacement.Text = "\2"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Size = 8
        .Superscript = False
        .Subscript = False
        .Position = -2
    End With
    With Selection.Find
        .Text = "([q])([0-9])"
        .Replacement.Text = "\2"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
      
   For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Italic = False
    Next equation
    
    'Selection.TypeText Text:=" "
    
    For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Name = "Arial"
    Next equation
          
End Sub

the Arrhenius equation

In the Arrhenius equation the activation energy has a subscript but is itself a superscript:

The best way to write it in Arial font size 11 is to have the exponential factor raised by 2 points but the small ‘a’ in size 8 and raised by only 1 point. The first code below will write the above with just 3 clicks – one to call up the list of macros, one to select the Arrhenius equation and one to run it.

The second code below will write the natural log version of the Arrhenius equation:

Sub ArrheniusEquation()
Selection.TypeText Text:="k = Ae"
    Selection.Font.Superscript = wdToggle
    With Selection.Font
        .Name = "Arial"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = True
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 2
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
    Selection.TypeText Text:=ChrW(8211) & "E"
    With Selection.Font
        .Name = "Arial"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = True
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 1
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
    Selection.Font.Size = 8
    Selection.TypeText Text:="a"
    Selection.Font.Size = 11
    With Selection.Font
        .Name = "Arial"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = True
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 2
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
    
      
    With Selection.Font
        .Name = "Arial"
        .Size = 16
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = True
        .Subscript = False
        .Spacing = -1
        .Scaling = 100
        .Position = -1
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
    
    Selection.TypeText Text:=" /"
    Selection.Font.Superscript = wdToggle
    
    
    With Selection.Font
        .Name = "Arial"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = True
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 2
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
    
    Selection.TypeText Text:=" RT"
    'Selection.Font.Superscript = wdToggle
    
    With Selection.Font
        .Name = "Arial"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
    
    Selection.TypeText Text:=" "
End Sub
Sub ArrheniusEquationNaturalLog()

 Selection.TypeText Text:="ln k = " & ChrW(8211) & " "
    
    Selection.OMaths.Add Range:=Selection.Range

    Selection.OMaths(1).Functions.Add(Selection.Range, wdOMathFunctionFrac). _
        Frac.Type = wdOMathFracBar
    Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdMove
    Selection.Font.Name = "Arial"
    Selection.TypeText Text:="Exxza"
    
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
    Selection.Font.Name = "Arial"
    Selection.TypeText Text:="RT"
    
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
    
    For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Name = "Arial"
    Next equation
    
    For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Italic = False
   Next equation
    
  Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Size = 8
        .Superscript = False
        .Subscript = False
        .Position = -1
    End With
    With Selection.Find
        .Text = "(xxz)(a)"
        .Replacement.Text = "\2"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Font.Italic = wdToggle
    Selection.Font.Name = "Arial"
     Selection.TypeText Text:="+ ln A"
     
     For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Name = "Arial"
    Next equation
End Sub

delete all headers and footers

Here at Southampton Exam Factory we have a lot of resources from an exam board for a now-defunct specification. The resources all have several footers and headers in gaudy textboxes with logos. Nobody cares now which section of the defunct syllabus the resources were created for. The macro below will remove them all with one click.

Sub RemoveHeaderAndFooter()

Dim oSec As Section
Dim oHead As HeaderFooter
Dim oFoot As HeaderFooter

For Each oSec In ActiveDocument.Sections
   
   For Each oHead In oSec.Headers
   If oHead.Exists Then oHead.Range.Delete
   Next oHead

   For Each oFoot In oSec.Footers
   If oFoot.Exists Then oFoot.Range.Delete
   Next oFoot
   
Next oSec

End Sub

add batch AutoCorrect entries

As explained here, AutoCorrect can be used to type in unformatted chemical formulae which then automatically add the correct subscripts and superscripts, or to type in an abbreviation which automatically expands to the long word or phrase. But it takes a long time to add each entry individually.

The link below is to a file created by Dave Rado:

https://wordmvp.com/Downloads/AutoCorrect.zip

Download the file and save it to your laptop. Opening the document will give you this message:

Pressing Backup will export your AutoCorrect table which can then be saved. Dozens of entries can then be added at the same time. Next time you open the document in the file above, press Restore and your expanded table is imported. Over time you can add hundreds of entries very easily.

The website below explains how to achieve the same result with a macro on the Quick Access toolbar:

add powers to a maths equation

When you make an equation using Insert>Equation you can’t use superscripts to get the powers. If you try to make the powers in a smaller font it just makes the whole expression into the smaller font. My colleague Lara Dune asked me how I produce such beautiful script as:

I used to place the expression over two lines with a line drawn in. Then I found that I could dispense with the line by underlining the top line of the expression, but this went awry when underlining the powers. Inserting a maths equation looks a lot better because it straddles the line as above, but the powers are then a problem. So I use the macro below which inserts the dummy expression above with the powers raised by 3 points and in font 8, while the remainder of the equation is in font 11. Change the characters to the ones you want then run the macro here over it to convert it to Arial.

If you are producing equilibrium resources and want an expression like this:

the minus sign has to be raised by 1.3 points.

Sub MathsEquationSuperscript()

Selection.OMaths.Add Range:=Selection.Range

    Selection.OMaths(1).Functions.Add(Selection.Range, wdOMathFunctionFrac). _
        Frac.Type = wdOMathFracBar
    Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdMove
    Selection.Font.Name = "Arial"
    Selection.TypeText Text:="[P]zxz2"
    
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
    Selection.Font.Name = "Arial"
    Selection.TypeText Text:="[Q]zxz3"
    
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
    
    For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Name = "Arial"
    Next equation
    
    For Each equation In ActiveDocument.OMaths
        equation.Range.Font.Italic = False
   Next equation
    
  Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Size = 8
        .Superscript = False
        .Subscript = False
        .Position = 3
    End With
    With Selection.Find
        .Text = "(zxz)([23])"
        .Replacement.Text = "\2"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
End Sub

find the Unicode value of a symbol

As described here, Aula Nerd often wants to know the Unicode value of a symbol. Pressing Alt + X after the symbol will give the Unicode (hex) value. The macro below will give the Unicode (decimal) value – just highlight the symbol you want then click the macro:

Sub GetUnicodeDecimal()

MsgBox "Unicode (decimal) is: " & AscW(Selection.Text)

End Sub

If you then want to use the symbol in a macro you use this line of code:

Selection.InsertSymbol Font:=”Arial”, CharacterNumber:=916, Unicode:=True

add a double bond

Are you still using an equals sign for a double bond? Here at Southampton Exam Factory we use Unicode (hex) symbol 268C which produces this:

I use AutoCorrect as detailed here to add my double bond: typing dbz AutoCorrects to the nice double bond.

See here for how to find the Unicode symbol for the double bond on the keyboard.

To find the Unicode symbol of any character use my macro here.

write the standard electrode potential sign

The quickest way to get the sign below is to have it as a macro and get it in three clicks:

The Greek capital letter theta is changed to font size 8, superscripted and raised by three points, all of which takes more than three clicks if you don’t use the macro.

Sub EStd()

'type E
Selection.TypeText Text:="E"
    
' change to superscript and make smaller
Selection.Font.Superscript = wdToggle
With Selection.Font
        .Name = "Arial"
        .Size = 8
        .Position = 3
End With
Selection.InsertSymbol Font:="Arial", CharacterNumber:=1012, Unicode:=True
    
' change back from superscript and add a space
Selection.Font.Superscript = wdToggle
With Selection.Font
        .Name = "Arial"
        .Size = 11
        .Position = 0
End With

Selection.TypeText Text:=" "
    
End Sub