I am trying to replace the content of a template word file and save the file as a new file. This is a console application
I am using VS 2019 and C#. I have added the Microsoft.office.Interop.word dll.
Application App = new Application();
WordDoc = App.Documents.Open(filepath); // This statement seems to be never ending . The file is 97-2003 word format file
WordDoc = App.Documents.Add(filepath); // Tried another way
WordDoc.Bookmarks["ABC"].Range.Text = "Test1" ; // want to replace the content ABC with Test1
I am not able to read the contents of the file . How to read the contents of the file and replace few text.
I have tried the Bookmark option, but getting error as system.runtime.interopservices.comexception - The requested member of the collection does not exist
How to fix this? Thanks