Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Determining the Month of the Year.
by Allen Wyatt
(last updated October 15, 2016)
When creating macros in VBA, you may have a need to know the specific month of the year, as represented by a particular date. For instance, you may want to determine the month in which the macro is being executed. The following code will do the trick:
iMonth = Month(Now())
The Month function returns an integer value representing the numeric month of whatever date you provide. In this example, the Now function represents today's date, and so Month returns the current month, as a value ranging from 1 to 12.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12343) applies to Microsoft Word 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Word here: Determining the Month of the Year.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
When processing a document in a macro, you may need to make some of your text bold. It's easy to do using the Bold attribute, ...Discover More
If your macro needs to know how many pages are in your document, you can use the Information method to get the desired info. ...Discover More
Macros can make life easier, as they provide a fast and efficient way of processing text in a document. Such is the case if ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.