在网上找到别人的调用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");
}
错误如下: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");
}
解决方案 »
- 运行时添加label控件到鼠标点击位置
- 出一个超级算法题,根据北京地铁运营图,求两点换乘次数最多的路线
- ora-02074 无法在分布式处理事务中Rollback
- 打开项目提示安装 WEB 控件,但是我已经安装。●●
- 急,求助!vb.net工程中触发的事件在C#工程中如何进行处理?
- 我想用C# 写 RS485门禁系统开发
- 关于main方法的疑问
- 如何将.net程序安装到没有装.net framework的机器上?
- 我的代码有重大错误吗?
- 【求助】C# 通过处理xml文以及其对应的xsd文件生成一张二维表格
- treeview 问题。 从A 移动到 B 单个没有问题 批量出现比较奇怪的事情。
- 关于序列化与反序列化
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");
}
coclass Application 的 uuid(000209FF-0000-0000-C000-000000000046)可能word的注册键出了问题,建议重装word