1 / 20

Other Features

Other Features. Index and table of contents Macros and VBA. Index and table of contents. In a large document, it is helpful to have a table of contents, and possibly and index as well.

gretchen
Download Presentation

Other Features

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Other Features • Index and table of contents • Macros and VBA

  2. Index and table of contents • In a large document, it is helpful to have a table of contents, and possibly and index as well. • Word can help generate these automatically for you and update them as the document is modified and page numbers change.

  3. To generate either one of these, use the Insert => Index and Tables…dialog box. • To generate a table of contents, select the Table of Contents tab:

  4. To generate an index, select the Index tab:

  5. To have Word create an index, you must specify which terms are to be indexed. • You can do this from this dialog box by either: • clicking the Mark Entry… button, which allows you enter individual terms; or • clicking the Automark… button, which allows you to specify a file where all the relevant terms have been stored.

  6. Macros • Macros are little programs that you can create to automate particular tasks that you may want to execute more easily than having to specify all the steps yourself every time you want to perform that task. • Macros can be created for use in any Microsoft Office application. • Here we consider simple macros for Word.

  7. Macros are actually written in a programming language called VBA (Visual Basic for Applications). • But simple macros can be created by just performing the operations once and letting the macro recorder in Word translate your actions into VBA. • To create a macro this way, use the Tools => Macro => Record New Macro… dialog box:

  8. If you want the macro you create to be invoked by a simple keystroke shortcut, you should click the Keyboard button and fill in the resulting dialog box. • Or, you can invoke your macro by selecting its name in the Tools => Macro => Macros… dialog box:

  9. Ways to create macros • You can create a macro from scratch by writing all the VBA code yourself, assuming you know VBA. • Or you can create a macro by just using the macro recorder. • Or you can do something in between, by first recording a macro, then making minor modifications to its VBA code to make it more powerful.

  10. A simple macro example • Here is the VBA code that results from recording these steps: • Set the font to Times New Roman and the font size to 12 points. • Type “Ronald J. Williams”, followed by Enter. • Do an Insert => Date … using a particular format and with automatic update set, followed by Enter. • Type “COM1105”, followed by Enter.

  11. And here’s what results from running this macro at the beginning of a blank document.

  12. Look at the VBA code again. Even when you don’t really understand VBA, it’s not too hard to infer what each line of this code does. • It’s also easy to see how you could modify it so that it selects other font types or sizes and how it puts text into the document.

  13. With very little VBA knowledge, you can make slight modifications to macros like this that do much more powerful things. • For example, suppose we want the macro to prompt the user for the course name rather than have it built in. • This macro cannot be created solely by using the macro recorder, but we can modify just one line of the previous code to create such a macro:

  14. The one line we’ve modified

More Related