
'Divide by 60 and add to the minutes total 'the previously recorded hours, minutes and seconds 'representing hours minutes and seconds and add to 'Split the found time into three separate numbers If oRng.Information(wdActiveEndSectionNumber) = sNum Then 'To count the whole document, omit the next line SNum = Selection.Information(wdActiveEndSectionNumber) The macro below will count all the times in the format HH:MM:SS in the section where the cursor is located. Of times associated with documented sound bites grouped in sections, similar to that shown in the illustration below.
Add form field shading word 2016 how to#
'Re-protect the form and apply the password (if any).Ī user in a Word forum asked how to total the number

SCount = oFld(mstrFF).CheckBox.Value 'Get the Checkbox field value SPassword = "" 'Insert the password (if any), used to protect the This can be achieved by checking the value of the check box and formatting the check box when the value is 'True'. In the following illustration the checked form field check box is coloured red. 'Select the first of the fields in the rangeĪctiveDocument.FormFields("MortText1").SelectĬolour a form field check box with a contrasting colour when it is checked. Type:=wdAllowOnlyFormFields, NoReset:=True, _ CalculateOnExit = False 'Uncheck the calculate on exit check box Enabled = True 'Enable the field for user entry Name = "MortText" & j 'Add a unique bookmark name 'Give each of the added fields a unique bookmark name 'Count the form fields added to the range Redefine the end of the range object.Ī "bMortgage", oRng FormFields.Add Range:=Selection.Range, Type:=wdFieldFormTextInput 'Ensure that the paragraphs stay together on the same page

This is where the cursor is at (start point) Selection.GoTo What:=wdGoToBookmark, Name:="bMortgage" SNum = ActiveDocument.FormFields("Mortgages").Result In the illustration, bookmarks are displayed to aid understanding. Will be readjusted to take account of that changed number. The user may return to the Mortgages field and change the number and the number of entries Iterations will be numbered from 8 - 16, 16 -24 etc. The bookmark names of the fields in that marked section will be replacedīy the macro, with the names "MortTextn" where 'i' is a numeric digit from 1 to 8. There are eight fields in the selection, each of which will be provided with a newīookmark name. Note that some of the text is underlined, some is emboldened and some both underlined and emboldened. Was set as a number field, the following macro was run on exit from thatįield, and the section to be repeated was bookmarked with the name 'bMortgage'. For the purpose of the exercise, the control field 'Mortgages' In the following example a user wished to provide a variable number of fieldsĪnd associated formatted text dependant on a figure input into a form field, as in the following Repeat a block of formatted text and form fields based upon the content of another form field Private Function GetCurrentFF() As Word.FormField Lbl_Exit: 'Re-protect the form and apply the password (if any). 'Colour the cells in the row from column 2 to the number entered

If sCount = 0 Then GoTo lbl_Exit 'If user enters 0, the row is 'Select each column of the active row in turn and colour the cellĪctiveDocument.Tables(1).Rows(sRow).Cells(i).Shading.BackgroundPatternColor If ActiveDocument.ProtectionType wdNoProtection ThenĪctiveDocument.Unprotect Password:=sPassword 'Check if the document is protected and if so unprotect it 'Get the number at the end of the bookmark name With GetCurrentFF 'Establish which dropdown field is current 'Insert the password (if any), used to protect the form between the
