您的位置:程序门 -> .net技术 -> c#



请高手指点:c#中如何打开word文档?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请高手指点:c#中如何打开word文档?[已结贴,结贴人:xzyangyuanyuan]
发表于:2007-03-29 11:34:39 楼主
请问如何在c#中打开word文件,我现在有word文件的路径?
请高手指点!
发表于:2007-03-29 11:39:081楼 得分:0
在工程中添加对word的引用

word.document   thisdocument   =   null;
word.application   thisapplication   =   null;//new   word.applicationclass();
createworddocument( "c:\temp.doc ",ref   thisdocument,ref   thisapplication);
thisapplication.showme()
发表于:2007-03-29 11:43:212楼 得分:0
process   viewerprocess   =   new   process();
viewerprocess.startinfo.filename   =   "c:\program   files\microsoft   office\office11\winword.exe ";
viewerprocess.startinfo.arguments   = "d:\xxx.doc ";
viewerprocess.start();
发表于:2007-03-29 11:44:133楼 得分:0
hertcloud(·£孙子兵法£·)   (   )   信誉:100         blog     2007-03-29   11:39:08     得分:   0    
 
 
      在工程中添加对word的引用

word.document   thisdocument   =   null;
word.application   thisapplication   =   null;//new   word.applicationclass();
createworddocument( "c:\temp.doc ",ref   thisdocument,ref   thisapplication);
thisapplication.showme()
   
 
----------------------------------
正解
发表于:2007-03-29 12:12:004楼 得分:0
请问,怎么在在工程中添加对word的引用?
发表于:2007-03-29 12:17:425楼 得分:0
using   microsoft.office.interop.word
谢谢
试一试!
发表于:2007-03-29 12:29:476楼 得分:0
我试了
我在工程中添加对word的引用,using   microsoft.office.interop.word,但是按上面提供的方法写的方法写的时候,报错为
"错误   找不到类型或命名空间名称“word”(是否缺少   using   指令或程序集引用?) "
是不是我引用错了,麻烦各位再指点指点啊,小弟不胜感激!
发表于:2007-03-29 13:13:377楼 得分:0
关注...帮顶
发表于:2007-03-29 13:34:408楼 得分:30
我也是碰到同样的问题!
发表于:2007-03-29 13:40:529楼 得分:0
system.diagnostics.process       proc       =       new       system.diagnostics.process();      
    proc.enableraisingevents=false;      
    proc.startinfo.filename= "winword ";      
    proc.startinfo.arguments= "c:\\dotnetstuff\\testworddoc.doc ";      
    proc.start();
发表于:2007-03-29 14:00:4610楼 得分:0
microsoft.office.interop.word
这个dll一般没有安装,可以下载一个
发表于:2007-04-03 23:20:2111楼 得分:10
我前两天才发贴问过这个问题,现在传给你:
要引用using   microsoft.office.interop.word,一般人只加了com组件:microsoft   office   11.0   object   library,   应该还要添加microsoft   word   11.0   object   library
发表于:2007-09-03 13:34:2812楼 得分:0
应该还要添加microsoft   word   11.0   object   library

上面个怎么添加啊?
发表于:2008-01-17 10:39:0413楼 得分:0
using       word=microsoft.office.interop.word
这样添加就可以了,嘿嘿,但是打开word文档的办法我还没有解决,那个兄弟可以给我一个完整的啊
发表于:2008-01-17 10:41:2814楼 得分:0
system.diagnostics.process               proc               =               new               system.diagnostics.process();              
        proc.enableraisingevents=false;              
        proc.startinfo.filename=   "winword   ";              
        proc.startinfo.arguments=   "c:\\dotnetstuff\\testworddoc.doc   ";              
        proc.start();
这个可以打开但是是用word   打开,不是在winform   里面打开,
还有
word.document       thisdocument       =       null;  
word.application       thisapplication       =       null;//new       word.applicationclass();  
createworddocument(   "c:\temp.doc   ",ref       thisdocument,ref       thisapplication);  
thisapplication.showme()  
        里面的
createworddocument()这个函数在哪里有啊,我找不到呢


快速检索

最新资讯
热门点击