views:

68

answers:

2

My job is to do a find and replace in .doc and .docx files which are saved in sharepoint document library. i have to alter all the documents in the document library by doing find and replace. please help me in this...

Open XML formats are only for word 2007 (.docx). I need single solution that would do find and replace in both .doc and .docx files. The library also contains .ppt,.pptx and excel sheets also..

A: 

I would recommend you to take a look at a third party tool from Aspose: http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx

This supports both .doc and .docx, and they also have a similar product for PowerPoint. My experience with Aspose is that they are of high quality and easy to implement.

aflyen
A: 

The best route to try is to look at "SharePoint Word Automation Services"

http://msdn.microsoft.com/en-us/library/ff742315.aspx

Below is an example from that link that should give you a good idea how to do this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.Office.Word.Server.Conversions;

class Program
{
    static void Main(string[] args)
    {
        string siteUrl = "http://localhost";
        // If you manually installed Word automation services, then replace the name
        // in the following line with the name that you assigned to the service when
        // you installed it.
        string wordAutomationServiceName = "Word Automation Services";
        using (SPSite spSite = new SPSite(siteUrl))
        {
            ConversionJob job = new ConversionJob(wordAutomationServiceName);
            job.UserToken = spSite.UserToken;
            job.Settings.UpdateFields = true;
            job.Settings.OutputFormat = SaveFormat.PDF;
            job.AddFile(siteUrl + "/Shared%20Documents/Test.docx",
                siteUrl + "/Shared%20Documents/Test.pdf");
            job.Start();
        }
    }
}
kyndigs
hi kyndigs: ya that is a good start, but i need some direct solution
arul xavier
like code snippet for find and replace in the document
arul xavier