Share via

Autocorrect text already written

Anonymous
2015-05-23T07:32:35+00:00

Hi community!

I'd like to replace several words by their respective abbreviations. I'v'e tried to add such abbreviations to the Autocorrection section, but it only works while typing, not now that the document is already written. It does not work when I copy and paste text either-even having Word set to match the destination formatting.

I've  found "Word find and replace software*"* which could be a solution.

Any ideas? Hope to hear news soon.

Thanks in advance.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2015-05-26T09:36:50+00:00

To remove the prompt (though you can see why I included it from your comments) change the loop as follows. The change also includes case matching.

Do While .Execute(FindText:=rFindText, _

                  MatchCase:=True, _

                  MatchWholeWord:=True, _

                  MatchWildcards:=False, _

                  Forward:=True, _

                  Wrap:=wdFindStop) = True

    oRng.Select

    'oRng.FormattedText = rReplacement.FormattedText

    oRng.Text = rReplacement.Text

    oRng.Collapse wdCollapseEnd

Loop

For guidance, see http://www.gmayor.com/installing_macro.htm

Was this answer helpful?

0 comments No comments

13 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-05-26T07:41:10+00:00

    Hi again!

    First of all, I'm sorry for the nonspecific vocabulary I might use, but I've come across the next issues:

    a) The macro asks me to confirm every single time it replaces a word

    b) The macro does not distinguishes formatting, so it changes "el salvador" when I specified (in the column) it should be "El Salvador".

    Also, I cannot find in your website some guidelines for noobs, which would be great.

    Hope to hear news soon.

    Thanks in advance!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-05-23T08:47:35+00:00

    It just requires a two column table, with no header row. Put the words you want to change in the first column and the abbreviations in the second column. Start with one row and as you tab out of the second cell a new row is created. Don't have any empty rows in the table.

    The format of the text is irrelevant for this exercise. Save the document and make a note of the filename and path.

    Change the value "C:\Path\Abbreviations.doc x" in the macro to the name and path of the table document you have created.

    The macro will replace the text with the format of the found words. If you want to include alternative formatting, then format the text in the second column as you want it to appear and move the apostrophe from the start of the first of the following lines and add it to the start of the second. i.e. change

    'oRng.FormattedText = rReplacement.FormattedText

    oRng.Text = rReplacement.Text

    to

    oRng.FormattedText = rReplacement.FormattedText

    'oRng.Text = rReplacement.Text

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-05-23T08:25:25+00:00

    First of all, thanks for replying so fast.

    Now, I am afraid I have never worked with macros, so I do not know how those two columns should be created.

    Also, would there be a similar solution to replacing foramtting, e.g. bold text to versalites?

    Thanks in advance!

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2015-05-23T08:02:03+00:00

    You could list the words and their abbreviations in a two column table and run the following macro to replace words from the first column with those corresponding from the second. http://www.gmayor.com/installing_macro.htm   

    Sub ReplaceFromTableList()

    Dim oChanges As Document, oDoc As Document

    Dim oTable As Table

    Dim oRng As Range

    Dim rFindText As Range, rReplacement As Range

    Dim i As Long

    Dim sFname As String

    Dim sAsk As String

        sFname = "C:\Path\Abbreviations.doc x" 'The table document

        Set oDoc = ActiveDocument

        Set oChanges = Documents.Open(Filename:=sFname, Visible:=False)

        Set oTable = oChanges.Tables(1)

        For i = 1 To oTable.Rows.Count

            Set oRng = oDoc.Range

            Set rFindText = oTable.Cell(i, 1).Range

            rFindText.End = rFindText.End - 1

            Set rReplacement = oTable.Cell(i, 2).Range

            rReplacement.End = rReplacement.End - 1

            With oRng.Find

                .ClearFormatting

                .Replacement.ClearFormatting

                Do While .Execute(FindText:=rFindText, _

                                  MatchWholeWord:=True, _

                                  MatchWildcards:=False, _

                                  Forward:=True, _

                                  Wrap:=wdFindStop) = True

                    oRng.Select

                    sAsk = MsgBox("Replace - " & vbCr & oRng & vbCr + vbCr & _

                                  "with - " & vbCr & rReplacement, vbYesNo, _

                                  "Replace from Table")

                    If sAsk = vbYes Then

                        'oRng.FormattedText = rReplacement.FormattedText

                        oRng.Text = rReplacement.Text

                    End If

                    oRng.Collapse wdCollapseEnd

                Loop

            End With

        Next i

        oChanges.Close wdDoNotSaveChanges

    lbl_Exit:

        Exit Sub

    End Sub

    Was this answer helpful?

    0 comments No comments