操作WORD文档,出现“内存不足,请现在保存文档。”错误
killu 2003-10-31 05:07:32 object fileName = "f:\\test\\test.doc";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
try{
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
try{
Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName,
ref missing,ref readOnly,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible
);
oWordDoc.Activate();
Response.Write(oWordApp.Documents.Creator);
oWordApp.Selection.TypeText("This is the text");
oWordApp.Selection.TypeParagraph();
oWordDoc.Save();
}catch(Exception ex){
Response.Write(ex.Message);
}finally{
oWordApp.Application.Quit(ref missing, ref missing, ref missing);
}
}catch (Exception ex2){
Response.Write(ex2.Message);
}