Listing Continued

nChapter = InputBox("What's the chapter number?")

' Get the total number of figures nFigures = InputBox("How many figures?")

' Insert the figure numbers

For i = 1 To nFigures

Selection.InsertParagraphAfter Selection.InsertAfter "Figure " & nChapter & ". Next 'i End Sub

This procedure uses the InputBox function to prompt for the chapter number (stored in the nChapter variable) and the total number of figures (stored in the nFigures variable). It then uses a For loop to add the figure numbers, first by inserting a paragraph and then by inserting the figure text. Figure 7.1 shows an example document with some figure numbers added by this macro.

Figure 7.1

Figure numbers inserted into a document by the code in Listing 7.5.

Figure 7.1

Figure numbers inserted into a document by the code in Listing 7.5.

0 0

Post a comment