请高手帮忙解决这个问题.现在正急着用呢.感谢!
//引用 microsoft word object 9.0 library
Word.ApplicationClass oWordApp = new Word.ApplicationClass(); //这里是产生错误的行!!!
object missing = System.Reflection.Missing.Value;
object filename = "c:\\myfile.doc";
Word.Document oWordDoc = oWordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
oWordDoc.Activate();
oWordApp.Selection.TypeText("This is the text");
oWordApp.Selection.TypeParagraph();
oWordDoc.SaveAs(ref filename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
oWordApp.Application.Quit(ref missing, ref missing, ref missing);
在office2003中引用的是11
代码如下:
using MSWord = Microsoft.Office.Interop.Word;
private MSWord.Application _wordApp = null;
protected void Button1_Click(object sender, EventArgs e)
{
_wordApp = new MSWord.Application(); //这里是产生错误的行!!!
_wordApp.Visible = true;
Object missing = Type.Missing;
Object sFileName = Server.MapPath("text\\Sample.doc");
MSWord.Documents docs = _wordApp.Documents;
MSWord.Document doc = docs.Add(ref missing, ref missing, ref missing, ref missing);
doc.SaveAs(ref sFileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
doc.Close(ref missing, ref missing, ref missing);
}
产生了错误: "检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005。"
我用的是vs2005 ,以上代码为什么会产生这种错误码.我试着修改过其权限,但还是报一样的错误码.office 2000跟office2003我都试过了.
望指教!
[此贴子已经被作者于2006-7-7 16:56:28编辑过]