在网上找到别人的调用word的原码,但是我刚着网上的做法做了!也添加了word object libabry 11.0还是报错。
错误如下:Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154.以下是原码:
        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");                         
        }

解决方案 »

  1.   

    http://download.csdn.net/source/392743,看一下这个老外写的例子,里面有乱码的地方自己改下吧!比较好用的!
      

  2.   


      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");                        
            } 
      

  3.   

    这个也没有给出具体解决办法,从网上查资料看问题好像是word使用权的问题!
      

  4.   

    OLE错误码0X80040154:Class not registered 
    coclass Application 的 uuid(000209FF-0000-0000-C000-000000000046)可能word的注册键出了问题,建议重装word
      

  5.   

    <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应用程序",右键打开属性对话框,点击"标识"选项卡,点"下列用户",把管理员的用户密码正确填写进去...点击"安全"选项卡,依次把"启动和激活权限","访问权限","配置权限",都选择为自定义,