Copy Example Code from Help

This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.

Sometimes you may want to copy a useful example from Visual Basic Help. While many of the examples require more code to work correctly, some examples are useful to see how a particular procedure or control flow technique behaves.

To copy example code from Help to your application

  1. Use Help to display the topic for the language element whose example you want to use.

  2. Click the Example link in the non-scrolling region near the top of the page. The code example is displayed.

  3. Right-click and select the part of the code you want to copy to your application. On the Macintosh, choose Copy from the Edit menu; a window appears in which you can select the code to copy.

  4. Choose Copy from the shortcut menu. On the Macintosh, press the Copy button.

  5. Move the focus back to the Code window and position the mouse pointer where you want the code example to be inserted.

  6. Right-click again and choose Paste to insert the code example into the Code window.

    TipTip

    You can also press CTRL+C to copy a selected example in a Help window. Press CTRL+V to paste the example into the Code window.

Show:
© 2014 Microsoft