Hello,
Below code which throws an exception, When run the Word2007 automation in System service context. This issue happened in Windows 8.1 system.
Guid clsid = new Guid("{000209FF-0000-0000-C000-000000000046}");
Type servreType = Type.GetTypeFromCLSID(clsid);;
object theServer = Activator.CreateInstance(ServerType);
Type typeof_Server = theServer.GetType();
typeof_Server.InvokeMember("Visible", BindingFlags.SetProperty, null, theServer
, new object[] { true });
typeof_Server.InvokeMember("DisplayAlerts", BindingFlags.SetProperty
, null, theServer, new object[] { false
});
object documents = typeof_Server.InvokeMember("Documents", BindingFlags.GetProperty, null, theServer, null);
object theActiveDocument = documents.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, documents
, new object[] { objFileName0, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing});
try
{
object sections = theActiveDocument.GetType().InvokeMember("Sections", BindingFlags.GetProperty
, null, theActiveDocument, null); // Exception thrown here.[
Exception from HRESULT: 0x800ADF21]
}
catch (Exception exp)
{
string strError = exp.Message;
}
Thanks
karthikeyan