Click here to Skip to main content
14,106,748 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am working on word automation . our system requires open word file and read file content and translate it to another language , then save each content its places.

I am thinking, word file includes pure text , table , and picture so on. how do I know the start position of table, picture as well as pure text section?

I reviewed articles about word automation. most of them about creating document and insert data something like that. when I read data from word file , it return the pure text as well as text in table. I need to read them separate ways with knowing what I am reading now .

what I need to do is : there is a word file ,
first open it
then from the beginning read pure text if there is pure text at beginning, then knowing the content of table if there a table after pure text section. in short I need to read data in sequence and make their content save them exact position.
how could I do that?

let's make my question simple.
if there is doc file, content like this :

//doc file-begin
I am from earch . my name is tom.
there is a table before me and after me.

//doc file - end
how can I read the first sentences without reading other parts?
how can do I know I read the first sentences and I am going to read table1?
then, read the second sentences, after that read table?
when I read doc file it returned the entire content of file. I need to read each part sepearatly.
is there somebody have experience in this matter? pls, help?

could any one help me ?

I thank you for your kind help and wait for right answer or tips
Updated 9-Mar-11 21:59pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

As you're new to the topic, I'm not sure you need exactly Word automation, which is only one approach to Word-related programming. Better start from this point:[^].

Ramalinga Koushik 27-Jun-11 6:14am
Nice Link SA.
Thank you, Ramalinga.
Ramalinga Koushik 29-Jun-11 23:53pm
It's my Pleasure.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I used the replacing methods, since I don't know how to save the format of word file ,it is better to analys it at sentences level and replace every single sentences by its translation. one more reason is there is no avaiable solution for that perpouse.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Every MS Office product has an object model. A table in a Word document is nothing more than an object of a class. Google the object model for a Word document and you will see a lot of hits for this...I don't know all of them off the top of my head. I usually do Office Automation through VBA when speaking to other Office products but the new VSTO is supposed to be better.

I also think that SA above provided a great link to look at as well.

Good luck.
Ramalinga Koushik 27-Jun-11 6:15am
Good Call Slacker.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is quite a big subject and you need to learn about the Interop[^] assemblies and how to get access to the Office types and their subsidiary objects.
This is a bit too general; and does not hint where to start.
You see, this is not exactly a case where you say "Google for it", so the Question makes sense as it is not clear where to start. You reference is not really helping. So, my 4. Please see my Answer.
Richard MacCutchan 9-Mar-11 16:28pm
I did not say "Google for it", I gave a list of MSDN links offering various articles on the subject that the OP needs to understand in order to achieve their objective. I don't see why your one answer is better than any of the ones I offered.
Manfred Rudolf Bihy 9-Mar-11 16:53pm
I agree, have my 5.
Richard MacCutchan 10-Mar-11 3:43am
Thanks, I'll try and remember to return the favour.
I meant to say "Google for it" would actually be better.
Rate this: bad
Please Sign up or sign in to vote.

Solution 5


if you already have some kind of translation mechanism then you can do it easily with this C# / VB.NET Word library that doesn't use C# Word Automation.

Here is a sample C# code:
// Use the component in free mode.

// Create an input document.
// You don't have to do this if you already have an input document.
// This code is only provided as a reference how input document could look like.
var document = new DocumentModel();
document.Sections.Add(new Section(document, new Paragraph(document, "Hello World!")));
// Instead use:
// Load an input document.
// var document = DocumentModel.Load("Document.docx", LoadOptions.DocxDefault);

// Iterate over all Runs in the document and translate their text.
foreach (Run run in document.GetChildElements(true, ElementType.Run))
	run.Text = TranslateTextSnippet(run.Text);

// Save the document to a file.
document.Save("Document.docx", SaveOptions.DocxDefault);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190518.1 | Last Updated 21 Feb 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100