
Tips.Net > WordTips Home > Macros > VBA Examples > Determining a Paragraph's Style in VBA
Summary: Use this code if your VBA macro needs the style name applied to a paragraph. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
Word allows you to use styles to format both paragraphs and individual characters in your document. These styles can greatly simplify the consistent application of formatting across an entire document. If you are writing a VBA macro, you may have a need to determine the name of the style applied to a particular paragraph. You can do that by using the Style property with a Paragraph object, as follows:
sParStyle = ActiveDocument.Paragraphs(J).Style
When this line is executed, sParStyle (a string variable) will contain the name of the style used on the specified paragraph.
Tip #824 applies to Microsoft Word versions: 97 2000 2002 2003
Ultimate Library! The most amazing collection ever offered in the history of WordTips places every tip—present and historical—at your fingertips. Check out the WordTips Ten-Year Library.
Uncover how you can master the full potential of printing your documents. Everything you wanted to know about printing and printers, using Word. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips