Hi, I am looking for a way to delete all AutoCorrect entries from a Word
2000 or XP installation.

I have written the following code:

=========================================
Sub DeleteACentries ()

Dim lngACcorrect as Long
lngACcorrect = Application.AutoCorrect.Entries.Count

For I = 1 To lngACcorrect
Application.AutoCorrect.Entries(I).Delete
Next I
Application.ScreenUpdating = True
MsgBox ("Ready!")

End Sub
==========================================


The "For" loop executes several times without errors, but stops after
exactly half of the total number of entries (the value of lngACcorrect),
with the following error message:

"5941 Requested member of collection does not exist."

What am I doing wrong? Why does the process keep stopping halfway? Does
the problem have to do with the existence of columns in the AC list? How
can I overcome the problem?

Kind regards.

AND

RE: How to all delete AutoCorrect entries by anonymous

anonymous
Tue Jan 27 07:46:05 CST 2004

Hi,

It _should_ stop after exactly half. That is, if you delete an item from a collection, then the number of items is less by one. You can get around this by running through the collection in reverse, as in the following

Sub DeleteACentries ()

Dim lngACcorrect as Long
lngACcorrect = Application.AutoCorrect.Entries.Count

For I = lngACcorrect to 1 Step -1
Application.AutoCorrect.Entries(I).Delete
Next I
Application.ScreenUpdating = True
MsgBox ("Ready!")

End Sub


I think this will suit your needs.

HTH,
Dave

Re: How to all delete AutoCorrect entries by Doug

Doug
Tue Jan 27 08:00:52 CST 2004

Say there were 4 entries

After deleting the 1st one there would be 4 left
After deleting the 2nd one, there would be 2 left
Some when you are trying to delete the 3rd, there is no 3rd one.

You must use

For I = lngACcorrect To 1 Step - 1

Then the 1st one that is deleted would be the 4th,
The 2nd one would be the 3rd
The 3rd one would be the 2nd
The 4th one would be the 1st

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"tomcat" <tomcat@nospam.invalid> wrote in message
news:1fgasziidugx$.mljvvctbl7q2.dlg@40tude.net...
> Hi, I am looking for a way to delete all AutoCorrect entries from a Word
> 2000 or XP installation.
>
> I have written the following code:
>
> =========================================
> Sub DeleteACentries ()
>
> Dim lngACcorrect as Long
> lngACcorrect = Application.AutoCorrect.Entries.Count
>
> For I = 1 To lngACcorrect
> Application.AutoCorrect.Entries(I).Delete
> Next I
> Application.ScreenUpdating = True
> MsgBox ("Ready!")
>
> End Sub
> ==========================================
>
>
> The "For" loop executes several times without errors, but stops after
> exactly half of the total number of entries (the value of lngACcorrect),
> with the following error message:
>
> "5941 Requested member of collection does not exist."
>
> What am I doing wrong? Why does the process keep stopping halfway? Does
> the problem have to do with the existence of columns in the AC list? How
> can I overcome the problem?
>
> Kind regards.
>
> AND



Re: How to all delete AutoCorrect entries by and

and
Tue Jan 27 08:28:14 CST 2004

YES!

Thanks, Dave and Doug. I was just starting to discover that my logic
wasn't so locical after all, and then your answers came. I have to count
down. That is all.

Thanks a bunch!

Re: How to all delete AutoCorrect entries by mail

mail
Tue Jan 27 22:34:10 CST 2004

Just for the sake of completeness, here's a way that doesn't involve counting:

For Each anentry In AutoCorrect.Entries
anentry.Delete
Next anentry

Regards,
Theo van der Ster


tomcat <tomcat@nospam.invalid> wrote in message news:<1fgasziidugx$.mljvvctbl7q2.dlg@40tude.net>...
> Hi, I am looking for a way to delete all AutoCorrect entries from a Word
> 2000 or XP installation.
>
> I have written the following code:
>
> =========================================
> Sub DeleteACentries ()
>
> Dim lngACcorrect as Long
> lngACcorrect = Application.AutoCorrect.Entries.Count
>
> For I = 1 To lngACcorrect
> Application.AutoCorrect.Entries(I).Delete
> Next I
> Application.ScreenUpdating = True
> MsgBox ("Ready!")
>
> End Sub
> ==========================================
>
>
> The "For" loop executes several times without errors, but stops after
> exactly half of the total number of entries (the value of lngACcorrect),
> with the following error message:
>
> "5941 Requested member of collection does not exist."
>
> What am I doing wrong? Why does the process keep stopping halfway? Does
> the problem have to do with the existence of columns in the AC list? How
> can I overcome the problem?
>
> Kind regards.
>
> AND

Re: How to all delete AutoCorrect entries by Word

Word
Wed Jan 28 03:55:32 CST 2004

G'day mail@sterlingwaen.com (Theo van der Ster),

try

with autocorrectentries
while .count>0
.item(1).delete
wend
end with

- tis much faster

Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


Theo van der Ster was spinning this yarn:

>Just for the sake of completeness, here's a way that doesn't involve counting:
>
>For Each anentry In AutoCorrect.Entries
> anentry.Delete
>Next anentry
>
>Regards,
>Theo van der Ster
>
>
>tomcat <tomcat@nospam.invalid> wrote in message news:<1fgasziidugx$.mljvvctbl7q2.dlg@40tude.net>...
>> Hi, I am looking for a way to delete all AutoCorrect entries from a Word
>> 2000 or XP installation.
>>
>> I have written the following code:
>>
>> =========================================
>> Sub DeleteACentries ()
>>
>> Dim lngACcorrect as Long
>> lngACcorrect = Application.AutoCorrect.Entries.Count
>>
>> For I = 1 To lngACcorrect
>> Application.AutoCorrect.Entries(I).Delete
>> Next I
>> Application.ScreenUpdating = True
>> MsgBox ("Ready!")
>>
>> End Sub
>> ==========================================
>>
>>
>> The "For" loop executes several times without errors, but stops after
>> exactly half of the total number of entries (the value of lngACcorrect),
>> with the following error message:
>>
>> "5941 Requested member of collection does not exist."
>>
>> What am I doing wrong? Why does the process keep stopping halfway? Does
>> the problem have to do with the existence of columns in the AC list? How
>> can I overcome the problem?
>>
>> Kind regards.
>>
>> AND