WordDocument object has no methods.

I have an ASP .Net Core 5 Web API, in which I am trying to do a Find and Replace on a Word document.
I'm using SyncFusion.EJ2.WordEditor.AspNet.Core 19.1.0.59

This is the code I am trying to implement:


using Syncfusion.EJ2.DocumentEditor; using (WordDocument document = new WordDocument())
{
    Stream docStream = File.OpenRead(Path.GetFullPath(@"../../../Template.docx"));
    document.Open(docStream, FormatType.Docx);
    docStream.Dispose();
    document.Replace("Cyles", "Cycles", true, true);
    docStream = File.Create(Path.GetFullPath(@"Result.docx"));
    doument.Save(docStream, FormatType.Docx);
    docStream.Dispose();
}


However, the "document" object (i.e. the instance of WordDocument) does not have a "Replace" method. In fact, it appears to have no methods at all. In Visual Studio 2019, if I type "document" and press fullstop on the keyboard, and the list of Intellisense suggestions comes up, there is only the stock "Dispose", "Equals", "GetHashCode", "GetObjectData", "GetType", and "ToString".


I'm not sure what I am doing wrong. I would greatly appreciate any suggestions..


Thank you.


1 Reply 1 reply marked as answer

HC Hemalatha Chiranjeevulu Syncfusion Team May 5, 2021 01:13 PM UTC

Hi Fabricio,

Thank you for contacting Syncfusion support.

From the details, we have found that your requirement is to replace the text in the Word document. To get the replace method of Word document object, we suggest you to use the below namespace in your sample application.

 
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO;
 


We have prepared the sample application to achieve your requirement and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/165138/ze/Sample1478144644

Please let us know if you have any other questions.

Regards,
Hemalatha C
 


Marked as answer
Loader.
Up arrow icon