Written by Allen Wyatt (last updated September 23, 2022)
This tip applies to Word 97, 2000, 2002, and 2003
There are numerous times when you are writing macros when you will need to determine if the user has made a selection. The following VBA code will let you know if a selection has been made. The variable designated to be a flag (InSelection) is first set to False, and then the Type property of the Selection object is used to determine if there is a selection. If so, then InSelection is set to True.
InSelection = False If Selection.Type = wdSelectionIP Then InSelection = True
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (127) applies to Microsoft Word 97, 2000, 2002, and 2003.
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 using a macro, you may need to know the precise size of a particular file. The way you figure ...
Discover MoreProgramming structures are an important tool used by any programmer. The VBA language used by Word's macros includes ...
Discover MoreA great place for your macro to display status information is, well, in the status bar. Displaying the information is ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-09-30 02:32:25
Anomander Rake
of just type:
InSelection = (Selection.Type = wdSelectionIP)
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments