How can I make a word visible when opening a document through interaction?

I want to open a text document through interop, and the word should be visible in the process. This looks pretty straight forward because there is a parameter called "visible in an open function in a text document." But the word is in What am I missing?

static void Main(string[] args) { Microsoft.Office.Interop.Word.Application word = null; word = new Microsoft.Office.Interop.Word.Application(); object inputFile = "c:\\test.docx"; object confirmConversions = false; object readOnly = true; object visible = true; object missing = Type.Missing; // Open the document... Microsoft.Office.Interop.Word.Document doc = null; doc = word.Documents.Open( ref inputFile, ref confirmConversions, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref visible, ref missing, ref missing, ref missing, ref missing); doc.Activate(); Console.ReadKey(); } 
+6
source share
1 answer

Hm. Obviously, both the application and the document should be visible. So the solution is to add a line (before doc.Activate ()):

 word.Visible = true; 
+6
source

Source: https://habr.com/ru/post/887831/


All Articles