How can I focus on the Word document that I just opened through interop?

I am writing a simple Word Interop application that opens a .doc file in the background, changes the contents of bookmarks, and then makes it visible to the user:

var App = new Microsoft.Office.Interop.Word.Application(); var ParTemplate = (object)Template; var ParVisible = (object)false; var Doc = App.Documents.Open( FileName: ref ParTemplate, // Template ConfirmConversions: ref missing, ReadOnly: ref missing, ... Doc.Activate(); Doc.SetBookmarkValue("IssueNumber", TheIssue.IssueNo); Doc.SetBookmarkValue("Title", TheIssue.Title); ... App.Visible = true; App.WindowState = WdWindowState.wdWindowStateNormal; 

In fact, the Word application appears on the taskbar, and the user must switch to it manually.

What is the best way to draw my application's attention to an open Word document?

+4
source share
1 answer

Try App.Activate(); instead of Doc.Activate() .

+5
source

All Articles