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 (
[email protected], 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.