i am creating a word add-in in c#, i am creating a document, inserting a hyperlink and trying to bring it front. but newly created document does not come in front. it goes to back of the current window. Below are the code :
Word.Document newNoteDoc = new Word.Document();
object oActiveDocFullName = Globals.ThisAddIn.Application.ActiveDocument.FullName;
object oAcitiveDocNameWithoutExt = Path.GetFileNameWithoutExtension(Globals.ThisAddIn.Application.ActiveDocument.Name);
object oActiveDocName = Globals.ThisAddIn.Application.ActiveDocument.Name;
object oScreenTip = (GeneralHelper.pstrNoteFolder + "\\" + txtFileName.Text.Trim() + ".docx").Replace('\\', '/');
object oScreemTipInNewDoc = Globals.ThisAddIn.Application.ActiveDocument.FullName.Replace('\\', '/');
object oMissingReference = System.Reflection.Missing.Value;
object oFileName = "file:///" + GeneralHelper.pstrNoteFolder + "/" + txtFileName.Text.Trim() + ".docx";
object oHyperlinkText = txtHyperlinkText.Text.Trim();
object oFileFormat = Word.WdSaveFormat.wdFormatDocumentDefault;
object oAddToRecentFiles = true;
object oReadOnlyRecommended = false;
object oStartRange = 0;
object oVisible = true;
Word.Range rngCurrentRange = Globals.ThisAddIn.Application.Selection.Range;
try
{
rngCurrentRange.Hyperlinks.Add(rngCurrentRange, ref oFileName, ref oMissingReference, ref oScreenTip, ref oHyperlinkText, ref oFileName);
Word.Range rngNewRange = newNoteDoc.Range(ref oStartRange, ref oMissingReference);
newNoteDoc.Hyperlinks.Add(rngNewRange, ref oActiveDocFullName, ref oMissingReference, ref oScreemTipInNewDoc, oAcitiveDocNameWithoutExt, oActiveDocFullName);
newNoteDoc.SaveAs2(ref oFileName, ref oFileFormat, ref oMissingReference, ref oMissingReference, ref oAddToRecentFiles, ref oMissingReference,
ref oReadOnlyRecommended, ref oMissingReference, ref oMissingReference, ref oMissingReference, ref oMissingReference,
ref oMissingReference, ref oMissingReference, ref oMissingReference, ref oMissingReference, ref oMissingReference, ref oMissingReference);
newNoteDoc.Close(ref oMissingReference, ref oMissingReference, ref oMissingReference);
object readOnly = false;
object isVisible = true;
object oMissing = System.Reflection.Missing.Value;
Word.Document NewDoc = Globals.ThisAddIn.Application.Documents.Open(ref oFileName, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible);
NewDoc.Activate();
still current document is active. how can i active the newly created document and bring to front.