Templates and Macros in MS Word RRS feed

  • Question

  • I am trying to create a set of templates that will need to have 2 or 3 common items changed each time they're used.  For example, I want to change the Company Name throughout the document to reflect a different company. I have found where to create a Macro to do that, but I am trying to figure out how to get it to ask me for the replacement company name.

    Below is the code it creates.  I believe that  .Replacement.Text = "IT Works" is about where I would guess it should ask for the company name I want to change "Sample" to.  Please help.

    Sub CompanyName()
    ' CompanyName Macro
        Selection.Find.Replacement.Font.Color = -587137025
        With Selection.Find
            .Text = "Sample"
            .Replacement.Text = "IT Works"
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub

    Thursday, September 7, 2017 4:36 PM