All the work is in the setup. Application once that's done is trivial.
Here's how you go about the setup:
1. Go to File|Info|Properties>Advanced Properties>Custom
2. Create 3 Custom properties - SpouseA, SpouseB, Sex, giving them the values 'Husband', 'Wife' and 'M', repsectively.
4. In your document, at the first location where you want the husband's name to appear in a husband's will, press Ctrl-F9 to create a pair of field braces (i.e. { }') and type 'DOCPROPERTY SpouseA' between them, so that you get {DOCPROPERTY SpouseA}.
5. Press F9 to update the display, then copy the field, which should now say 'Husband', to wherever else you want it to appear.
6. Repeat steps 4 & 5 for the SpouseB property, for wherever the wife's name is to appear.
You should now have a basic setup, with 'Husband' and 'Wife' showing in all the right places. Now go back to the custom document properties dialog and swap 'Husband' and 'Wife', then switch back to the document and either press Ctrl-A, F9 or do a print preview, and you should see all the 'Husband' and 'Wife' references have swapped over in the document. It's that simple. Undo those changes for now.
Continuing with the Sex document property:
1. Select a location where the text should say he/she.
2. Press Ctrl-F9
twice to create a nested pair of field braces (i.e. { { } }')
3. Fill in the field braces so that you get {IF{DOCPROPERTY Sex}= "M" "he" "she"}, making sure you have all the spaces indicated.
4. Press F9 to update the display, then copy the field, which should now say 'he', to wherever else you want he/she to appear.
5. Repeat steps 3 & 4 for the 'him/her', 'his/her' & 'husband/wife' variable content.
6. Do the same for where the M/F outputs should be inverted, as in, for example, {IF{DOCPROPERTY Sex}= "M" "she" "he"}
Now go back to the custom document properties dialog and swap 'Husband' and 'Wife', and change the Sex property to 'F', then switch back to the document and either press Ctrl-A, F9 or do a print preview, and you should see all the 'Husband' and 'Wife' and he/she, etc. references have swapped over in the document. Simple as.
Now for some simple tweaks with the SpouseA & SpouseB properties. So far, the field outputs will be exactly the same as the property values, without regard to formatting.
You apparently want some of the outputs to be All-Caps. For that, you can simply apply the \* Upper switch to the applicable DOCPROPERTY field, as in:
{DOCPROPERTY SpouseA \* Upper}
Of course, if you only ever want the spouse names to be in Upper case, you could just input them into the SpouseA & SpouseB properties that way and skip this switch.
You also apparently want some of the outputs to be Bold. For that, you can simply apply the \* CHARFORMAT switch to the applicable DOCPROPERTY field and apply bold formatting to at least the 'D' of 'DOCPROPERTY', as in:
{
DOCPROPERTY SpouseA \* CHARFORMAT}
You can even combine that with the \* Upper switch, as in:
{
DOCPROPERTY SpouseA \* Upper \* CHARFORMAT}
That should take care of the setup. From now on, all you need do is update the three custom document properties, then refresh the document's display. And that could be automated with a macro as simple as:
Code:
Sub WillSetup()
With ActiveDocument
.CustomDocumentProperties("SpouseA").Value = Trim(InputBox("Testator:"))
.CustomDocumentProperties("Sex").Value = UCase(Left(Trim(InputBox("Testator's Sex:")),1))
.CustomDocumentProperties("SpouseB").Value = Trim(InputBox("Beneficiary:"))
.Fields.Update
End With
End Sub
Swapping them once they've been input is as simple as:
Code:
Sub WillSwap()
With ActiveDocument
Dim StrTmp As String: StrTmp = .CustomDocumentProperties("SpouseA").Value
.CustomDocumentProperties("SpouseA").Value = .CustomDocumentProperties("SpouseB").Value
.CustomDocumentProperties("SpouseB").Value = StrTmp
Select Case UCase(.CustomDocumentProperties("Sex").Value)
Case "M": .CustomDocumentProperties("Sex").Value = "F"
Case "F": .CustomDocumentProperties("Sex").Value = "M"
End Select
.Fields.Update
End With
End Sub
No user input required!
See attached demo.
The various fields described above are accessible via Insert|Quick Parts>Field, but that's difficult to use for the IF tests associated with the he/she conditional outputs.
For more on fields and field switches, see:
List of field codes in Word - Microsoft Support
Format field results - Microsoft Support