日期:2014-05-19  浏览次数:20821 次

求助,不为分值-C#操作Office相关
C#操作Office相关的资料谁有,本人正在网上搜集,可是不够啊,
例如打开word,
关闭保存   word,
写入文字,
比对:我看到过一个考试系统,他可以对学生做的word文档或者PPt能判分,我不知道是怎么实现的,也不知道C#能不能实现呢?

------解决方案--------------------
http://www.ieee.org.cn/dispbbs.asp?boardID=43&ID=27403
http://www.cnblogs.com/Dragon-China/archive/2007/04/03/698371.aspx
------解决方案--------------------
private Word.ApplicationClass oWordApplic;Word application
private Word.Document oDoc= new Word.ApplicationClass();

//打开WORD
public void Open(string strFileName)
{
object fileName = strFileName;
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;

oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);

oDoc.Activate();
}

//新建
public void New( )
{
object missing = System.Reflection.Missing.Value;
oDoc = oWordApplic.Documents.Add(ref missing, ref missing, ref missing, ref missing);

oDoc.Activate();
}

//关闭
public void Quit( )
{
object missing = System.Reflection.Missing.Value;
oWordApplic.Quit(ref missing, ref missing, ref missing);
oWordApplic=null;
GC.Collect();
GC.WaitForPendingFinalizers();
}

//插入文本
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}