Re: Getting the list of Autocorrect enties in word



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, jialge@xxxxxxxxxxxxxxxxxxxx
(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/managed/Default.aspx?dg=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/subscriptions/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/library/aa163987(office.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/details.aspx?familyid=3c9a983a-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 (jialge@xxxxxxxxxxxxxxxxxxxx, 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.
.



Relevant Pages

  • Re: "Entry Type" field missing values
    ... presented with a list of the journal entries I have made. ... details correct except for the missing values in "Entry Type" and Start ... another interesting thing: I can hit Ctrl-Shift-F. ...
    (microsoft.public.office.developer.outlook.forms)
  • Re: Getting the list of Autocorrect enties in word
    ... microsoft.public.word.programming is not a managed queue, ... application.Quit(ref missing, ref missing, ref missing); ... entry = application.AutoCorrect.Entries.get_Item(ref ... other Windows Installer aware setup editor. ...
    (microsoft.public.dotnet.general)
  • Re: Regex find and replace - delete line
    ... If you want to delete entries from @file completely... ... that _equal_ to 'foo' (and the entry does not contain a line ending): ... If I'm missing something, I blame the fact that it's only six in the ...
    (perl.beginners)
  • Validation List
    ... I'm trying to setup a validation list that would ... automatically add new entries to the list upon approval from the user, ... other words, ill setup a warning that would say 'entry does not exist, would ... should work for all cell with a drop down for a specific list, ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Applications missing from Add or Remove Programs ...
    ... each one represents a entry for Add/Remove. ... If no entries are present or only a small number, ... >missing in the list. ... This also includes every Windows Update/Hotfix entry ...
    (microsoft.public.windowsxp.general)