using Word = Microsoft.Office.Interop.Word; //using
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word.Document oDoc;
oWord = new Word.ApplicationClass();
//oWord.Visible = true;
object fileName = @"E:\\模板.doc"; oDoc = oWord.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
代码如上,运行到oWord.Documents.Open()方法时就报:
无法将类型为“Word.ApplicationClass”的 COM 对象强制转换为接口类型“Word._Application”。此操作失败的原因是对 IID 为“{00020970-0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: RPC 服务器不可用。 (异常来自 HRESULT:0x800706BA)。 真的郁闷的无可救药啦 望高手赐教!
office2003也是完全安装,也引用啦COM,library11.0,这个错误具体是什么不清楚,已经困扰我两天啦。。只要是执行oWord的方法就回报这个错误。望高手指教,谢谢!
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word.Document oDoc;
oWord = new Word.ApplicationClass();
//oWord.Visible = true;
object fileName = @"E:\\模板.doc"; oDoc = oWord.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
代码如上,运行到oWord.Documents.Open()方法时就报:
无法将类型为“Word.ApplicationClass”的 COM 对象强制转换为接口类型“Word._Application”。此操作失败的原因是对 IID 为“{00020970-0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: RPC 服务器不可用。 (异常来自 HRESULT:0x800706BA)。 真的郁闷的无可救药啦 望高手赐教!
office2003也是完全安装,也引用啦COM,library11.0,这个错误具体是什么不清楚,已经困扰我两天啦。。只要是执行oWord的方法就回报这个错误。望高手指教,谢谢!
void WordBL::CallWordScore(System::String ^CnoIndex)
{
KillApp("WORD");
System::Object ^a = System::Reflection ::Missing ::Value ;
Word::ApplicationClass ^WordApp = gcnew Word::ApplicationClass();
WordBL::WordDoc = WordBL::WordApp->Documents->Open(WordBL::FileName, a, a, a, a, a, a, a, a, a, a, a,a,a,a,a);
int c =System::Convert::ToInt32 (CnoIndex);
switch( c)
{
case 001: this->GetMark001(); break;
case 002: this->GetMark002(); break;
/*case "003": this.GetMark003(); break;
case "004": this.GetMark004(); break;
case "005": this.GetMark005(); break;
case "006": this.GetMark006(); break;
case "007": this.GetMark007(); break;
case "008": this.GetMark008(); break;
case "009": this.GetMark009(); break;
case "010": this.GetMark010(); break;*/
default: this->GetMark001(); break;
}
this->KillApp("WORD"); //关闭Word程序
// //SaveScore("update_ExamScore_Word",CommonClass.Tester.Sno,"@WordScore",Score);
System::Windows ::Forms ::MessageBox ::Show (" 提交答案成功 ");
} 执行的Open语句的时候,提示的错误也是:无法将类型为“Word.ApplicationClass”的 COM 对象强制转换为接口类型“Word._Application”。此操作失败的原因是对 IID 为“{00020970-0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: RPC 服务器不可用。 (异常来自 HRESULT:0x800706BA)。