I am trying to update word doucment using bookmark from an ASP.Net page.
Development environment has Windows 7 64, Office 2010, Office runtime
using Microsoft.Office.Interop.Word;
try
{
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
Document wordDoc = new Document();
object fileName = "E:\\Employee.docx";
object readOnly = false;
object isVisible = true;
object oMissing = System.Reflection.Missing.Value;
wordApp.Documents.Open(fileName, ref oMissing, readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, isVisible, ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
wordDoc.Activate();
if (wordDoc.Bookmarks.Exists("EmployeeName"))
{
object oBookmark = "EmployeeName";
wordDoc.Bookmarks.get_Item(ref oBookmark).Range.Text = "me";
}
wordApp.Documents.Save(ref oMissing, ref oMissing);
wordApp.Application.Quit(ref oMissing, ref oMissing, ref oMissing);
}
catch (Exception expn)
{
Response.Write("<br>" + expn.Message);
}
I am getting error message:
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Created folder C:\Windows\SysWOW64\config\systemprofile\Desktop also in System32/config/systemprofile/Desktop and assigned Network Services with appropriate rights
Then, did:
In DCOMCNFG, right click on the My Computer and select properties.
2. Choose the COM Securities tab
3. In Access Permissions, click "Edit Defaults" and add Network Service to it and give it "Allow local access" permission. Do the same for <Machine_name>\Users.
4. In launch and Activation Permissions, click "Edit Defaults" and add Network Service to it and give it "Local launch" and "Local Activation" permission.
Still having the same issue, any workaround will be appreciated.