Link to home
Start Free TrialLog in
Avatar of Brandon Garnett
Brandon Garnett

asked on

Inserting text into a word document using a macro

I am trying to write a macro to insert a word at the beginning of each paragraph based on a selection in a Microsoft Word document.  For example, "1. Some text here" would change to "WORD 1. Some text here" after running the macro.  So far I have this, but I only want the Macro to run with a selection, not the whole document.

Sub addNotes()

    iParCount = ActiveDocument.Paragraphs.Count
    For j = 1 To iParCount
        sMyPar = "Note " + ActiveDocument.Paragraphs(j).Range.Text
        ActiveDocument.Paragraphs(j).Range.Text = sMyPar
    Next j

End Sub

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brandon Garnett
Brandon Garnett

ASKER

That worked like a charm, thanks.