Find & Replace - Editing Question

T

Tricia

Hi :D
With word, is there a way or an add-on that I can use for this:

When I run the spell check I want condition to change to cond.

I know you can use the find & replace, but there are some words I use a lot
and it would be a lot easier if the spell check just picked these words up
and changed them. I can't use autocorrect to do it because most of the text
I work with is copy and pasted.

Can't wait to hear what you think!
 
G

Graham Mayor

The short answer is no. Spell check does not work like this. You can,
however do it with a macro.

Create a document with two column table containing the words to replaced in
the left column and their replacements in the right. Then save it as a
document and close it..

With your document active, run the following macro to use that table to make
the changes in your document: In the following macro, change the line

sFname = "D:\My Documents\Test\changes.doc" to reflect the name and path of
the document containing the table.

Sub ReplaceFromTableList()

Dim ChangeDoc As Document, RefDoc As Document
Dim cTable As Table
Dim oldPart As Range, newPart As Range
Dim i As Long
Dim sFname As String

sFname = "D:\My Documents\Test\changes.doc"
Set RefDoc = ActiveDocument
Set ChangeDoc = Documents.Open(sFname)
Set cTable = ChangeDoc.Tables(1)
RefDoc.Activate
For i = 1 To cTable.Rows.Count
Set oldPart = cTable.Cell(i, 1).Range
oldPart.End = oldPart.End - 1
Set newPart = cTable.Cell(i, 2).Range
newPart.End = newPart.End - 1
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Execute findText:=oldPart, _
ReplaceWith:=newPart, _
Replace:=wdReplaceAll, _
MatchWholeWord:=True, _
MatchWildcards:=False, _
Forward:=True, _
Wrap:=wdFindContinue
End With
End With
Next i
ChangeDoc.Close wdDoNotSaveChanges
End Sub

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Janine

Tricia,

You could also make use of autocorrect where the documents are not typed
already, say, if you type cond it stays cond and if you type condition it
becomes cond:

cond = cond
condition = cond

Of course you can use any abbreviations you like.

Janine
 
T

Tricia

Hi Graham,

Thanks for your help, I finally have time to try it. I have no experience
with macros, but I have followed your advice, and this is exactly what I have
(see below) and it says: this command will stop the debugger and/or compile
error: Expected End Sub.

I know I have screwed it up somewhere. If you have spare time could you
please tell me what you think about it.

Tricia


Sub Macro4()
'
' Macro4 Macro
'
'
Sub ReplaceFromTableList()

Dim ChangeDoc As Document, RefDoc As Document
Dim cTable As Table
Dim oldPart As Range, newPart As Range
Dim i As Long
Dim sFname As String

sFname = "C:\Users\Tricia\Documents\TraderMacro.doc"
Set RefDoc = ActiveDocument
Set ChangeDoc = Documents.Open(sFname)
Set cTable = ChangeDoc.Tables(1)
RefDoc.Activate
For i = 1 To cTable.Rows.Count
Set oldPart = cTable.Cell(i, 1).Range
oldPart.End = oldPart.End - 1
Set newPart = cTable.Cell(i, 2).Range
newPart.End = newPart.End - 1
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Execute findText:=oldPart, _
ReplaceWith:=newPart, _
Replace:=wdReplaceAll, _
MatchWholeWord:=True, _
MatchWildcards:=False, _
Forward:=True, _
Wrap:=wdFindContinue
End With
End With
Next i
ChangeDoc.Close wdDoNotSaveChanges
End Sub
 
G

Graham Mayor

sFname is defined in the line
sFname = "C:\Users\Tricia\Documents\TraderMacro.doc"
is that path correct?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Tricia

SUCCESS!! Thankyou your the best :D

The problem was: the document was not saved as 'doc' it was saved as 'docx'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top