Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Word document not visible when opening programmatically through interop

The following code opens the document in the background but not make it visible even though I am using Visible = true and oDoc.Activate();

using Word = Microsoft.Office.Interop.Word;
Word.Application oApp = new Word.Application();
Word.Document oDoc = oApp.Documents.Open(FileName: @"C:\Folder1\Test1.docx", Visible: true);
oDoc.Activate();

According to this SO post, it should have worked.

like image 241
nam Avatar asked Dec 06 '25 03:12

nam


1 Answers

It looks like you forgot to set the Visible property of the Application class.

See How to automate Microsoft Word to create a new document by using Visual C# for more information.

like image 83
Eugene Astafiev Avatar answered Dec 08 '25 23:12

Eugene Astafiev