请教:C#如果读取Word文档中的内容,读取Word2003和Word2000方法是否相同 有说做过类似操作Word的东西啊,提供点资料吧,急啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该是你引用的类库的问题应该将你引用的word类库打包,进行安装,应该就没有问题了 jialiang(≈≈逆水行舟≈≈) 可否说的详细一点,我引用了Interop.Word.dll,eWord.dll 我做的是在OA系统中读取Word,怎么进行word类库打包,进行安装啊?以下是写的读取Word正文内容的方法:WordPhysicsPath为Word所在的物理路径请个各位帮我分析一下为什么在Window2000+Office2000下会出现Object reference not set to an instance of an object.的异常public string GetDocContentOut(string WordPhysicsPath) { try { string WordContent = ""; ApplicationClass app = new ApplicationClass(); object fileName = WordPhysicsPath; object optional=Missing.Value; object visible=true; if(File.Exists(WordPhysicsPath)) { Word.Document doc = app.Documents.Open(ref fileName,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref visible,ref optional,ref optional,ref optional); object first = 0; object units = WdUnits.wdCharacter; object last=doc.Characters.Count; WordContent = doc.Range(ref first, ref last).Text; object saveChanges = WdSaveOptions.wdDoNotSaveChanges; object originalFormat = Missing.Value; object routeDocument = Missing.Value; app.Quit(ref saveChanges, ref originalFormat, ref routeDocument); } else { WordContent = "指定目录下的无该文件"; } return WordContent; } catch(Exception Ex) { return Ex.Message ; } } } 把office目录下的一些dll,好像是word.dll, mso.dll,一起打包,如果目标机器没有安装word2003,则需要把以上文件copy 到目标机器上并注册使用,手工注册可以使用regsvr32 fullname命令的方式。 参数上有点差别吧,EXCEL也是这样的 我做excel的程序,不同的程序参数是有区别的。所以每次都得先判断excel的版本,特别烦 C#调用命令行在Windows2008下没有响应 richtextbox显示图片问题 C# 中 字符串如何转化为 struct 编辑xml时根据schema提示要添加的元素信息 我想在Form上的一个pictureBox上用鼠标画线为什么就不行 物体碰撞判断2 在线等!高手们帮忙呀! 有关打印--在线等---急 NetBox打包生成exe问题,再发一帖,求助 picturebox问题 请教关于使用DataReader和DataGrid配合使用显示数据的问题 寻一本学asp.net的很精典的编程书
应该将你引用的word类库打包,进行安装,应该就没有问题了
可否说的详细一点,我引用了Interop.Word.dll,eWord.dll
我做的是在OA系统中读取Word,怎么进行word类库打包,进行安装啊?
以下是写的读取Word正文内容的方法:
WordPhysicsPath为Word所在的物理路径
请个各位帮我分析一下为什么在Window2000+Office2000下会出现Object reference not set to an instance of an object.
的异常
public string GetDocContentOut(string WordPhysicsPath)
{
try
{
string WordContent = "";
ApplicationClass app = new ApplicationClass();
object fileName = WordPhysicsPath;
object optional=Missing.Value;
object visible=true;
if(File.Exists(WordPhysicsPath))
{
Word.Document doc = app.Documents.Open(ref fileName,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref visible,ref optional,ref optional,ref optional);
object first = 0;
object units = WdUnits.wdCharacter;
object last=doc.Characters.Count; WordContent = doc.Range(ref first, ref last).Text;
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Quit(ref saveChanges, ref originalFormat, ref routeDocument); }
else
{
WordContent = "指定目录下的无该文件";
}
return WordContent;
}
catch(Exception Ex)
{
return Ex.Message ;
}
} }