I am writing a simple Word Interop application which open a .doc file in background, changes bookmarks content, then make 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;
Actually, the Word application appears in the task tray, and the user has to switch to it manually.
What is the best way to make my application focus on the opened Word document ?
Try this App.Activate();
instead of Doc.Activate()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With