日期:2014-05-18 浏览次数:20918 次
private void button1_Click(object sender, EventArgs e) { Word.ApplicationClass wd = new Word.ApplicationClass(); object oMissing = System.Reflection.Missing.Value; wd.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); Word.Document doc = wd.ActiveDocument; wd.Visible = false; object extend = null; object unit = null; object count = 0; object character; extend = Word.WdMovementType.wdExtend; unit = Word.WdUnits.wdCell; wd.Selection.Move(ref unit, ref count); wd.Selection.TypeText("会议通知"); //换行 wd.Selection.MoveRight(ref unit, ref count, ref extend); count = 2; character = Word.WdUnits.wdCharacter; wd.Selection.Move(ref character, ref count); wd.Selection.TypeText("eeeeeee"); }
------解决方案--------------------
OLE错误码0X80040154:Class not registered
coclass Application 的 uuid(000209FF-0000-0000-C000-000000000046)
可能word的注册键出了问题,建议重装word
------解决方案--------------------
<system.web>
<identity impersonate="true" userName="administrator" password="11111111"/>
</system.web>
检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 8000401a 。
运行dcomcnfg打开组件服务,
依次展开"组件服务"->"计算机"->"我的电脑"->"DCOM配置"
找到"Microsoft Excel应用程序"或"Microsoft Word应用程序",
右键打开属性对话框,点击"标识"选项卡,
点"下列用户",把管理员的用户密码正确填写进去...
点击"安全"选项卡,
依次把"启动和激活权限","访问权限","配置权限",都选择为自定义,