We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Search a text in a word document (.doc or .docx)

Is this available now ?
I just want to search for a text in a word document (.doc or .docx) and not replace ?

Whilst we are fully licensed for ASPOSE products, I am not sure if the feature is available ?

@Jackson94 Sure, you can use Document.Range.Replace and ReplaceAction.Skip to simply search a text in the document and do not replace it. For example, see the following code:

Document doc = new Document(@"C:\Temp\in.docx");
FindReplaceOptions opt = new FindReplaceOptions();
SearchOnlyCallback searchOnlyCallback = new SearchOnlyCallback();
opt.ReplacingCallback = searchOnlyCallback;
doc.Range.Replace("test", "", opt);
Console.WriteLine("The text 'test' found {0} times.", searchOnlyCallback.Occurrences);
private class SearchOnlyCallback : IReplacingCallback
{
    public ReplaceAction Replacing(ReplacingArgs args)
    {
        mOccurrences++;
        return ReplaceAction.Skip;
    }

    public int Occurrences
    {
        get { return mOccurrences; }
    }

    private int mOccurrences = 0;
}

Thanks for your response, appreciate

Is there a way to search for .EML (Email), .VMBX and .MSG files as well ?

VMBX and EML appear to be working with ASPOSE.WORDS but .MSG’s are failing,

is there a way to search for .MSG, EXCEL, zips - can you please send me an example where these could be searched for a text ?

@Jackson94 To work with .MSG files you should use Aspose.Email. You can use Aspose.Email to convert .MSG file to .MHTML, which can then can be loaded by Aspose.Words. Or use Aspose.Email API to process this type of files.
Excel files can be processed using Aspose.Cells.
You can use Aspose.ZIP product to extract files from .ZIP archives and then use the appropriate Aspose API to search text in the files extracted from the achieve.

Thanks for your response.

Can you send me an example for Email (MSG’s) to be searched for ?
Also for XLS or XLSX ?

@Jackson94,

Regarding searching text in Excel (XLS/XLSX) files using Aspose.Cells, see the document on how to find or search data in the worksheet(s) for your reference.

@Jackson94 You can load .MSG file into MimeMessage class and parse its content. Or you can save the MimeMessage as Mhtml, load the resulting Mhtml file using Aspose.Words and use Aspose.Words to search for text in the document.