Hi everyone,
I found this great code from Gregy Maxey/Doug Robbins. I didmy 2 col table
and it throws it into Autocorrect in less time than it takes to blink. But
I would like to add a few formatted entries. I realise that is a little more
complex? I did attempt to do true/false but it was over my head).
Any ideas if it can be done easily?
Sub MultiAutoCorrectGenerator()
'Adapted by Greg Maxey from MultiFindAndReplace code
'provided by Doug Robbins
Dim oDoc As Document
Dim i As Integer
Dim Wrong As Range
Dim Right As Range
Set oDoc = ActiveDocument
Selection.Tables(1).Cell(1, 1).Range.Select
Selection.Collapse
For i = 2 To oDoc.Tables(1).Rows.Count
If oDoc.Tables(1).Rows(i).Cells(1).Range.Characters.Count > 1 Then
Set Wrong = oDoc.Tables(1).Cell(i, 1).Range
Wrong.End = Wrong.End - 1
Set Right = oDoc.Tables(1).Cell(i, 2).Range
Right.End = Right.End - 1
AutoCorrect.Entries.Add Name:=Wrong, Value:=Right
End If
Next i
End Sub
Jezebel - 09 Sep 2006 02:16 GMT
AutoCorrect can't handle formatting. If you want formatting you need to use
AutoText instead --
Sub MultiAutoTextGenerator()
Dim i As long
With Selection.Tables(1)
For i = 2 To .Rows.Count
ActiveDocument.AttachedTemplate.AutoTextEntries.Add _
Name:=ActiveDocument.Range(.Cell(i,1).Range.Start,
.Cell(i,1).Range.End - 1), _
Range:=ActiveDocument.Range(.Cell(i,2).Range.Start,
.Cell(i,2).Range.End - 1)
Next
end with
End Sub
> Hi everyone,
> I found this great code from Gregy Maxey/Doug Robbins. I didmy 2 col table
[quoted text clipped - 26 lines]
> Next i
> End Sub
Joacim - 09 Sep 2006 05:08 GMT
> AutoCorrect can't handle formatting. If you want formatting you need to
> use AutoText instead --
[quoted text clipped - 45 lines]
>> Next i
>> End Sub
Jay Freedman - 09 Sep 2006 03:25 GMT
For the formatted entries, replace the line
AutoCorrect.Entries.Add Name:=Wrong, Value:=Right
with
AutoCorrect.Entries.AddRichText Name:=Wrong, Range:=Right
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>Hi everyone,
>I found this great code from Gregy Maxey/Doug Robbins. I didmy 2 col table
[quoted text clipped - 25 lines]
>Next i
>End Sub
Joacim - 09 Sep 2006 04:44 GMT
I feel like a ...... SO.... GOOD. Works a treat.
> For the formatted entries, replace the line
>
[quoted text clipped - 42 lines]
>>Next i
>>End Sub
Joacim - 09 Sep 2006 16:29 GMT
Hi Jay,
Works great 2003 and I assume backwards too.
But doesn't work in 2007 - I am guessing the VBA code has been BLOCKED so to
speak? Or is it XML based?
Has anyone looked into this as yet?
Joacim
> For the formatted entries, replace the line
>
[quoted text clipped - 42 lines]
>>Next i
>>End Sub
Joacim - 09 Sep 2006 16:32 GMT
Disregard - it worked fine- just had a different order?
Thank you - saves me a lot of work...
> Hi Jay,
>
[quoted text clipped - 54 lines]
>>>Next i
>>>End Sub