ReplaceText

ITextFrame.ReplaceText méthode

Remplace toutes les occurrences du texte spécifié par un autre texte spécifié.

public void ReplaceText(string oldText, string newText, ITextSearchOptions options, 
    IFindResultCallback callback)
ParamètreTypeDescription
oldTextStringLa chaîne à remplacer.
newTextStringLa chaîne pour remplacer toutes les occurrences de oldText.
optionsITextSearchOptionsOptions de recherche de texte ITextSearchOptions.
callbackIFindResultCallbackL’objet de rappel pour recevoir les résultats de recherche IFindResultCallback.

Exemples

Le code d’exemple suivant montre comment remplacer une chaîne spécifiée par une autre chaîne spécifiée.

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx"))
{
	// Remplacer toutes les occurrences séparées de 'the' par '***'
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.ReplaceText("the", "***", new TextSearchOptions()
	{ WholeWordsOnly = true }, null);
	presentation.Save("SomePresentation-out2.pptx", SaveFormat.Pptx);
}

Voir aussi