Article ID: 173707 - View products that this article applies to.
This article was previously published under Q173707
For a Microsoft Office XP version of this article, see 290140
For a Microsoft Office 2000 version of this article, see 212536
For a Microsoft Office 2001 for Mac version of this article, see 274703
For a Microsoft Office 98 Macintosh Edition version of this article, see 181058
The Microsoft Knowledge Base contains a number of articles that contain sample code for Visual Basic for Applications macros. Many of these macros illustrate basic concepts of programming in Visual Basic for Microsoft Office. This article contains instructions on how to use the sample code to create a new macro, and how to run that macro.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
(http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)Microsoft Excel stores macros in workbooks; Microsoft PowerPoint stores macros in presentations, and Microsoft Word stores macros in templates and documents. To use the sample code in a Knowledge Base article, you must add a new Visual Basic macro (or select an existing macro) in an Excel workbook, PowerPoint presentation or Word template or document. You can then paste or type the sample code into this macro. Use any of the following methods.
To Create a New Macro
and the last line:
To add the sample code to the macro using the Clipboard, follow these steps:
To Add the Sample Code to a ModuleTo add code to a module, you must either have an existing module or create a new module. To do this, follow these steps:
To Run the Macro
Microsoft Help for each Office program contains numerous topics about working with macros. Visual Basic help contains extensive information about writing your own code.
For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/163435/EN-US/ )VBA: Programming Resources for Visual Basic for Applications
Article ID: 173707 - Last Review: March 29, 2007 - Revision: 3.6