
Tips.Net > WordTips Home > Macros > WordBasic Examples > Determining if a Text Selection Has Been Made in WordBasic
Summary: Sometimes your macro needs to know if the user made a selection before starting the macro. Here's how to figure it out. (This tip works with Microsoft Word 6, and Word 95.)
There are numerous times when you are writing macros when you will need to determine if the user has made a selection. The following WordBasic code will let you know if a selection has been made. It sets the value of a flag, InSelection, to -1 (True) if there is currently a selection. Otherwise InSelection is set to 0 (False).
InSelection = 0 If SelType() = 2 or SelType() = 6 Then InSelection = -1
Tip #126 applies to Microsoft Word versions: 6 95
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful "wildcard searches" available in Word.
Check out WordTips: Find and Replace today!
Do you want a decade of WordTips information at your fingertips? You can find what you need with the WordTips Ten-Year Library. (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