By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 1,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

Getting the list of Autocorrect enties in word

P: n/a
I need to get the list of Autocorrect entries in word. Is there a way
to do it without connecting to Word? Is the list saved somewhere?
If I need to connect to Word, how can I detect if it's installed on
the user machine?
Thanks.
Andrea
Aug 20 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hello Andrea,

From your post, my understanding on this issue is: you want to get the
auto-correct entries in Word. If I'm off base, please feel free to let me
know.

If you are using Office 2003/2002, please refer to the kb article:
http://support.microsoft.com/kb/826147 or
http://support.microsoft.com/kb/269006/EN-US/. Office 2002/2003 has a
'AutoCorrect Utility' in C:\Program Files\Microsoft
Office\Office\Macros\SUPPORT.DOT, which can help you export the
auto-correct entries. In Word 2000, the utility is located in C:\Program
Files\Microsoft Office\Office\Samples\Macros9.dot (see:
http://support.microsoft.com/kb/207748/EN-US/). As to Office Word 97 or 95,
please refer to http://support.microsoft.com/kb/186237/EN-US/ or
http://support.microsoft.com/default...&Product=wrd97
Aug 21 '07 #2

P: n/a
Hello Andrea,

Thank you for the quick reply. I notice that you once posted a same issue
in the queue: microsoft.public.word.programming on 2007-8-7
(http://msdn.microsoft.com/newsgroups...microsoft.publ
ic.word.programming&mid=5ea81601-1a30-4aec-ab55-a0c6a8dc89fb)
microsoft.public.word.programming is not a managed queue, thus we were not
notified about that post and we did not jump in. The following link refers
to a list of all the managed queues where the replies are ensured.
http://msdn2.microsoft.com/en-us/sub.../aa974230.aspx
1. I've attached to MS Word 2007. What should I do to get the autocorrect
from Office 2003?
In the post dated on 2007-8-7, I notice that your actual need is to export
the auto-correct entries of Office Word 2003 into a text file with a C#
program. If I'm off base, please feel free to let me know.
First, we need to find a computer installed with Office 2003 Word and
Office 2003 PIA. Add the reference to Microsoft Word 11.0 Object Library in
your C# project.
Secondly, try the following C# code list to export the Word 2003
autocorrect entries into a txt file:
using System;
using System.Collections.Generic;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
object missing = Type.Missing;
Word.Application application = new Word.Application();
int total = GetAutoCorrectEntries(application);
application.Quit(ref missing, ref missing, ref missing);
}
public static int GetAutoCorrectEntries(Word.Application
application)
{
StreamWriter writer = new StreamWriter(@"D:\entries.txt");
int TotalACEntries = application.AutoCorrect.Entries.Count;
string entry;
for (int x = 1; x <= TotalACEntries; x++)
{
object index = (object)x;
entry = application.AutoCorrect.Entries.get_Item(ref
index).Name;
entry += "\t";
entry += application.AutoCorrect.Entries.get_Item(ref
index).Value;
writer.WriteLine(entry);
}
writer.Close();
return TotalACEntries;
}
}
}
The code above will help you create a txt file containing all entries:
D:\entries.txt.
The format of the pairs is : name\tvalue. For instance, abbout about
Therefore, it is quite easy to parse this entry list of Word 2003 into a
hash table or dictionary from the txt file when you are using Office 2007.
StreamReader reader = new StreamReader(@"D:\entries.txt");
string line = reader.ReadLine();
Hashtable entries = new Hashtable();
while (line != null)
{
string[] parts = line.Split('\t');
entries.Add(parts[0], parts[1]);
line = reader.ReadLine();
}
reader.Close();
2. What files should I distribute with my application. I saw VS2005 added
a reference to Microsoft.Office.Core, Microsoft.Office.Interop.Word and
VBIDE.
They are components of Office PIA.
If you are using Office XP, please refer to the section "Distributing
Solutions That Reply On the Office XP PIAs" of the following MSDN article:
http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

if you are using Office 2003, The only supported redistribution method is
to use the Office 2003 Update: Redistributable Primary Interop Assemblies
http://www.microsoft.com/downloads/d...83a-ac14-4125-
8ba0-d36d67e0f4ad&displaylang=en. According to the Readme shipped with the
package, we have the following choice. To install the Office 2003 Primary
Interop Assemblies, follow one of the following methods:
1 Double-click the O2003PIA.msi file
2 Execute "msiexec.exe /i O2003pia.msi", or
3 Wrap the O2003pia.msi in another setup package through Visual Studio or
other Windows Installer aware setup editor.
Please note that the Office 2003 Primary Interop Assemblies setup does not
support the /a or /j options for MsiExec.
For the third option, I think you may try to take a look at the link below.
How To Create a Nested .msi Package http://support.microsoft.com/?id=306439

Also we have specified queue about setup project, if you still have any
concern ,please feel free to post there, so that experienced expert will
give you more idea.
microsoft.public.platformsdk.msi or microsoft.public.vstudio.setup

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 22 '07 #3

P: n/a
Thanks Jialang,

I tried your code and it works on both Word 2003 and Word 2007.
Before I tried the Office12 object model which offers the ability to
detect if the Autotext was in RichText format. Is there a way to
detect it in Office 2003?
Thanks,
Andrea
On Wed, 22 Aug 2007 04:25:44 GMT, ji****@online.microsoft.com
(Jialiang Ge [MSFT]) wrote:
>Hello Andrea,

Thank you for the quick reply. I notice that you once posted a same issue
in the queue: microsoft.public.word.programming on 2007-8-7
(http://msdn.microsoft.com/newsgroups...microsoft.publ
ic.word.programming&mid=5ea81601-1a30-4aec-ab55-a0c6a8dc89fb)
microsoft.public.word.programming is not a managed queue, thus we were not
notified about that post and we did not jump in. The following link refers
to a list of all the managed queues where the replies are ensured.
http://msdn2.microsoft.com/en-us/sub.../aa974230.aspx
>1. I've attached to MS Word 2007. What should I do to get the autocorrect
from Office 2003?
In the post dated on 2007-8-7, I notice that your actual need is to export
the auto-correct entries of Office Word 2003 into a text file with a C#
program. If I'm off base, please feel free to let me know.
First, we need to find a computer installed with Office 2003 Word and
Office 2003 PIA. Add the reference to Microsoft Word 11.0 Object Library in
your C# project.
Secondly, try the following C# code list to export the Word 2003
autocorrect entries into a txt file:
using System;
using System.Collections.Generic;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
object missing = Type.Missing;
Word.Application application = new Word.Application();
int total = GetAutoCorrectEntries(application);
application.Quit(ref missing, ref missing, ref missing);
}
public static int GetAutoCorrectEntries(Word.Application
application)
{
StreamWriter writer = new StreamWriter(@"D:\entries.txt");
int TotalACEntries = application.AutoCorrect.Entries.Count;
string entry;
for (int x = 1; x <= TotalACEntries; x++)
{
object index = (object)x;
entry = application.AutoCorrect.Entries.get_Item(ref
index).Name;
entry += "\t";
entry += application.AutoCorrect.Entries.get_Item(ref
index).Value;
writer.WriteLine(entry);
}
writer.Close();
return TotalACEntries;
}
}
}
The code above will help you create a txt file containing all entries:
D:\entries.txt.
The format of the pairs is : name\tvalue. For instance, abbout about
Therefore, it is quite easy to parse this entry list of Word 2003 into a
hash table or dictionary from the txt file when you are using Office 2007.
StreamReader reader = new StreamReader(@"D:\entries.txt");
string line = reader.ReadLine();
Hashtable entries = new Hashtable();
while (line != null)
{
string[] parts = line.Split('\t');
entries.Add(parts[0], parts[1]);
line = reader.ReadLine();
}
reader.Close();
>2. What files should I distribute with my application. I saw VS2005 added
a reference to Microsoft.Office.Core, Microsoft.Office.Interop.Word and
VBIDE.
They are components of Office PIA.
If you are using Office XP, please refer to the section "Distributing
Solutions That Reply On the Office XP PIAs" of the following MSDN article:
http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

if you are using Office 2003, The only supported redistribution method is
to use the Office 2003 Update: Redistributable Primary Interop Assemblies
http://www.microsoft.com/downloads/d...83a-ac14-4125-
8ba0-d36d67e0f4ad&displaylang=en. According to the Readme shipped with the
package, we have the following choice. To install the Office 2003 Primary
Interop Assemblies, follow one of the following methods:
1 Double-click the O2003PIA.msi file
2 Execute "msiexec.exe /i O2003pia.msi", or
3 Wrap the O2003pia.msi in another setup package through Visual Studio or
other Windows Installer aware setup editor.
Please note that the Office 2003 Primary Interop Assemblies setup does not
support the /a or /j options for MsiExec.
For the third option, I think you may try to take a look at the link below.
How To Create a Nested .msi Package http://support.microsoft.com/?id=306439

Also we have specified queue about setup project, if you still have any
concern ,please feel free to post there, so that experienced expert will
give you more idea.
microsoft.public.platformsdk.msi or microsoft.public.vstudio.setup

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=============================================== ==
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=============================================== ==
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 23 '07 #4

P: n/a
Hello Andrea,

Yes, Office 2003 can also detect rich text format by using the property
'RichText' of AutoCorrectEntry object. For instance:

if (application.AutoCorrect.Entries.get_Item(ref index).RichText)
application.AutoCorrect.Entries.get_Item(ref
index).Apply(application.Selection.Range);

Both Office 2007 and Office 2003 support this property.

Please feel free to let me know if you have any other concern.

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 23 '07 #5

P: n/a
Thanks.
One more thing. I noticed that if the entry is in RichTextFormat I get
an * symbol in the string (the Value property). Is there a way to get
properly formatted text?
Thanks,
Andrea

On Thu, 23 Aug 2007 10:24:21 GMT, ji****@online.microsoft.com
(Jialiang Ge [MSFT]) wrote:
>Hello Andrea,

Yes, Office 2003 can also detect rich text format by using the property
'RichText' of AutoCorrectEntry object. For instance:

if (application.AutoCorrect.Entries.get_Item(ref index).RichText)
application.AutoCorrect.Entries.get_Item(ref
index).Apply(application.Selection.Range);

Both Office 2007 and Office 2003 support this property.

Please feel free to let me know if you have any other concern.

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=============================================== ==
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=============================================== ==
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 23 '07 #6

P: n/a
Hi Andrea,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 28 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.