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

Free Support Forum - aspose.com

Text Find/Replace

What I’m interested in doing is a “find/replace” in all MS Office file types…word, powerpoint, excel…etc. Can this also work on outlook emails…e.g. .msg and .pst files?

I downloaded your “slides” java examples but there are a TON of them and couldn’t find a good “find/replace” example. After reading the Features Overview I think i’m looking for something along the lines of the “Text Scanning” functionality? Can you point me in the right direction to a good example, if there is one?

Thank you!

Aspose provides rich features set including text find and replace in its different products. Following is the detail for each product:

Review the following article where a number of examples are given to find and replace text.
Find and Replace

Regarding the sample code for Aspose.Slides, please try the following sample code:

Presentation presentation = new Presentation("samplepptx.pptx");
String strToReplace = "Done";
ITextFrame[] tb = SlideUtil.getAllTextFrames(presentation, true);
String find = "sample";
String strToFind= "(?i)\\b"+find+"\\b";
for (int i = 0; i < tb.length; i++)
	for (IParagraph ipParagraph : tb[i].getParagraphs())
		for (IPortion iPortion : ipParagraph.getPortions())
				iPortion.setText(iPortion.getText().replaceAll(strToFind, strToReplace));

You can search the text and then replace using the following sample codes:
Find and replace in spreadsheet

You may also try following articles where number of techniques are given for searching text which can be replaced later using putValue() function.
Find or Search Data

Find and search text requires little different mechanism for messages and PST files. For example, the simplest code to find and replace text in the message body is given below:

MailMessage m = MailMessage.Load("GenerateMSGAspose.msg");

bool ifcontain = m.HtmlBody.Contains("[@@<span class=\"SpellE\">FullName</span>@@]");
m.HtmlBody = m.HtmlBody.Replace("[@@<span class=\"SpellE\">FullName</span>@@]", "Adnan Ahmad");
m.BodyEncoding = Encoding.ASCII;
m.Save("tested.msg", SaveOptions.DefaultMsg);

As messages and PST files are not simple documents, so you need to parse the messages and PST files and then find and replace text in different headers and properties. For this please visit the following articles where processing with messages and Outlook files is given in detail:
Working with MIME messages
Working with Outlook items
Working with Outlook storage files

You may try the sample codes in the above-mentioned articles and feel free to write us back if you have any query or issue while working with them. We will provide you assistance at the earliest.