0

Am working on an application that needs to count words from documents and revisions.

as you can see here, I have already resolved this for Word Documents (well, as much it can be resolved) but now i find myself wondering how to get that data from Excel or PowerPoint documents.

The MSDN Documentation didn't help so far - i will keep looking but if anyone knows the answer i would appreciate a little help.

EDIT: So taking the information provided by @Andrew (Thanks go to him) i got this code for the Excel part:

foreach (Excel._Worksheet s in ExcelBook.Sheets)
        {
            if (s.UsedRange.Value2 != null)
            {
                for (int i = 1; i <= s.UsedRange.Value2.GetLength(0); i++)
                {
                    for (int j = 1; j <= s.UsedRange.Value2.GetLength(1); j++)
                    {
                        string content = s.UsedRange.Value2[i, j];
                        MessageBox.Show(i + " - " + j + " - " + content);
                    }
                }
            }
        }

Now i can use that to count words in all cells in the Sheet, however that still doesn't help with revisions - anyone has an idea on how to follow up on this?

Community
  • 1
  • 1
537mfb
  • 1,374
  • 1
  • 16
  • 32

2 Answers2

2

It appears from the code example that you linked to that Word's OM gives you access to its revision tracking feature. Handy.

PowerPoint has no revision tracking whatever, so there's nothing for you to work with unless as Andrew has suggested, you extract and store the text from a presentation at one point, then later do the same and compare the two. Getting at the text, most of it anyhow, isn't all that difficult. Comparing two sets of text looking for revisions could be quite complex.

There are some VBA macros for extracting regular text on slides here (disclaimer: my site): http://www.pptfaq.com/FAQ00274.htm

These are simple-minded and won't deal with text in grouped shapes, tables, charts and so on, but they'll get you started.

Steve Rindsberg
  • 3,470
  • 1
  • 16
  • 10
  • Thanks - had that much already - will probably do what you suggest but like you said it's complex - Excel though does have track changes, only i don't see them anywhere in the OM. turning ListchangesOnNewSheet to true doesn't seem to help much either as for some reason rolling through the sheets never get's to the history sheet – 537mfb Sep 08 '11 at 15:26
1

You should try this.

It helped me few months ago. It is a very nice tutorial on CodeProjects.

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
  • Ok - That helped me know how to read contents from cells - can use that to count total words, but doesn't even mention revisions - check the question - i need to count words in revision (how many added, how many deleted) - your answer helped a bit though - thanks – 537mfb Sep 08 '11 at 08:32
  • There is no history in your application? Something like "file history"? For example: program opens file in morning, count words and save informations. During day someone opens file, make some changes and your program in evening opens file and count words and you know difference. Isn't it what you want? – Ondrej Janacek Sep 08 '11 at 11:08
  • My applications will do the count on files that were created and changed in Office by the translators and reviewers - My application is just a final step to evaluate the translation quality based on how much was changed in review. Both translaters and reviewrs work from home so i only have access to the files when they deliver - good idea though - Also i need to know how many words got added and how many got deleted - knowing was 1000 words in morning and 1001 in evening doesn't give me that - could be 1 word added or 800 deleted and 801 added - different - thanks for the input – 537mfb Sep 08 '11 at 15:29