Search code examples
c#excelinteroppowerpointrevisions

How to get revisions from Excel or PowerPoint Files in C# using Interop?


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?


Solution

  • 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.