Microsoft KB Archive/222730

= PPT2000: Sample Visual Basic Code Displays Each Word of Selection in Message Box =

Article ID: 222730

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q222730





SUMMARY
This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) that displays a message box for each word in a selection.



MORE INFORMATION
For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

Sample Visual Basic Procedure
NOTE: This code generates a run-time error if you have not selected any text before you run the macro. Sub GetWords

' Dimension the variables. Dim oTextRange As TextRange Dim i As Long

' Get reference to the selected text. Set oTextRange = ActiveWindow.Selection.TextRange

' Loop through the words in the selection. For i = 1 To oTextRange.Paragraphs.Words.count

' Output each word in a message box. MsgBox oTextRange.Paragraphs.Words(i, 1)

Next i

End Sub

