Hi Everyone:
I did a search before asking this, but could not find anything, so I apologize if this has already been asked. I am creating a macro in Word, but I only want the Macro to run on the text that I select within Word - how would you do this Thank you very much to anyone that can help!

Re: MS Word Macro Help

Riquel Dong ¨C MSFT

Hi Spphat,

Move this thread from VB language forum. This forum supports Visual Basic.NET (7, 7.1, 8, ...) issues only, so your VBA question is an off-topic here and this isn't the best place to ask it.You can visit VBA support forum to get an answer about your question.

Thanks for your question

Re: MS Word Macro Help


I cannot be sure unless I see the code. If you want to select the text use the selection.range

Assuming your macro will loop through the paragraphs in the selection, I have given the hint

Code Snippet

Sub RunMacroWithin_Selected_Range()

Dim rngSelected As Range
Dim para As Paragraph

Set rngSelected = Selection.Range

For Each para In rngSelected.Paragraphs

MsgBox para

Next para

End Sub