How to Edit Bookmarks in a Word Document using Universal Windows App

2

I am building a Universal Windows application(UWP) which need to the add text to the bookmarks in a Microsoft Word Document.

I added the library Microsoft.Office.Interop.Word and included the below code that can add text to the bookmarks:

Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();

Microsoft.Office.Interop.Word.Document oDoc;

object oTemplate = filepath;

oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);

oDoc.Bookmarks["BookmarkName"].Range.Text = "BookmarkText";

Error Message:

System.IO.FileLoadException HResult=0x80131515 Message=Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. Operation is not supported. (Exception from HRESULT: 0x80131515) Source=BuyOutApp StackTrace: at BuyOutApp.DocumentsGenerated.TemplateRFQs.GenerateBearingPadRFQ() in C:\Users\s.raja\Source\Workspaces\Workspace2\Buyout Application\BuyOutAppSln\BuyOutApp\DocumentsGenerated\TemplateRFQs.cs:line 43 at BuyOutApp.Views.OutputShellPage.BtnSubmit_Click(Object sender, RoutedEventArgs e) in C:\Users\s.raja\Source\Workspaces\Workspace2\Buyout Application\BuyOutAppSln\BuyOutApp\Views\OutputShellPage.xaml.cs:line 239 Inner Exception 1: NotSupportedException: A Primary Interop Assembly is not supported in AppX.

uwp
.net-core
ms-word
office-interop
windows-10-universal
asked on Stack Overflow May 29, 2019 by Sandeep Raja • edited May 30, 2019 by Cindy Meister

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0