N
N
Nikita072020-04-25 18:54:39
WPF
Nikita07, 2020-04-25 18:54:39

Why does the event handler not fire completely?

Hello everyone, there is a small WPF program, it has a button responsible for sending data to Word, but when you click on the button, nothing happens (more precisely, it only saves, but the Word document does not open, although this is written in the code)
If you click the button again time, then the handler will be executed normally, what could be the reason?

GIF
5ea45c9218dc7268840981.gif

Button code

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
            Document doc = app.Documents.Add(Visible: true);
            doc.Save();
            app.Documents.Open(@"C:\1.docx");


PS From the 1st time, Word itself opens (it hangs in the task manager, but in background processes), from the 2nd time, Word goes to the Application in the task manager

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-04-25
@yarosroman

https://github.com/UNIT6-open/TemplateEngine.Docx and no need to fence your bike. Well, don't ask the same question over and over again. But if you wish, put a pause between opening and saving.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question