网上有很多关于DOC转TXT的文章,但都是前提系统要安装有word,然后用word的组件进行“另存为"的转换,如果不安装word有没有办法直接转换呢?希望有高人指点,送上100分。

解决方案 »

  1.   

    好象有的记事板是可以直接打开DOC的,去找下那种记事本看看,可能只能看的到文字,格式应该会变化的
      

  2.   

    要自己分析DOC的文件,然后进行转换....找找网上有没有DOC格式分析之类的文章吧
      

  3.   

    在VB中将WORD文档读入文本文档再导出为文本文件,代码也不是很多,也很简单.
      

  4.   

    记事本是不行的,用写字板可以
    自己分析doc格式,肯定不哪么容易,但wps office却可以轻松打开、保存为doc,说明金山公司有可能已分析明白DOC格式了!
    个人分析,貌似...
      

  5.   

    将DOC文件转换成无格式的TXT文件:Option Explicit   
       
      Public   Function   GetDocText(ByVal   sFQFilename   As   String)   As   String   
      '提取Word文档的纯文本。   
      'INPUT-----------------------------------------------------------   
      'sFQFilename                         Word文档的全路径名   
      'OUTPUT----------------------------------------------------------   
      'Return   Value                       提取的纯文本   
      '----------------------------------------------------------------   
        
      Dim   Wapp   As   Object,   Doc   As   Object     'Word   Application   对象、Document   对象   
        
      try:   On   Error   GoTo   catch   
      '{   
              Set   Wapp   =   CreateObject("Word.Application")   '创建Word   Application   对象   
              Set   Doc   =   Wapp.Documents.Open(sFQFilename)   '打开文档,返回一个文档对象   
              GetDocText   =   Doc.Content.Text   '提取纯文本   
      '}   
      GoTo   finally   
      catch:   
      '{   
              GetDocText   =   ""   
      '}   
      finally:   
      '{   
              '如果文档对象不为空,那么说明打开了文档,关闭它,并销毁文档对象   
              If   Not   (Doc   Is   Nothing)   Then   Doc.Close:   Set   Doc   =   Nothing   
              '如果word   application对象不为空,那么说明创建了word对象,   
              '退出它,并销毁对象   
              If   Not   (Wapp   Is   Nothing)   Then   Wapp.Quit:   Set   Wapp   =   Nothing   
      '}   
        
      End   Function   
        
      Public   Function   HasWordInstalled()   As   Boolean   
      '判断用户的电脑是否安装有word。如果没有安装word或是word版本过低(无法提供外部可创建对象)   
      '则返回FALSE。   
      Dim   Wapp   As   Object   
        
      On   Error   Resume   Next   
        
      Err.Clear   
        
      Set   Wapp   =   CreateObject("Word.Application")   
        
      If   Err   =   0   Then   '无错误,创建成功,说明安装了Word,返回真   
              HasWordInstalled   =   True   
                
              '释放资源   
              Wapp.Quit:   Set   Wapp   =   Nothing   
      Else   
              HasWordInstalled   =   False   '有错误发生,返回FAlSE   
      End   If   
        
      End   Function   
       Public   Function   GetDocText(ByVal   sFQFilename   As   String)   As   String   
      '提取Word文档的纯文本。   
      'INPUT-----------------------------------------------------------   
      'sFQFilename                         Word文档的全路径名   
      'OUTPUT----------------------------------------------------------   
      'Return   Value                       提取的纯文本   
      '----------------------------------------------------------------   
        
      Dim   Wapp   As   Object,   Doc   As   Object     'Word   Application   对象、Document   对象   
        
      try:   On   Error   GoTo   catch   
      '{   
              Set   Wapp   =   CreateObject("Word.Application")   '创建Word   Application   对象   
              Set   Doc   =   Wapp.Documents.Open(sFQFilename)   '打开文档,返回一个文档对象   
              GetDocText   =   Doc.Content.Text   '提取纯文本   
              '***********************************************   
              '加上这几句,是保存GetDocText的内容到一个新的Word里,分段标志还在,但是首行缩进标志没了   
              Set   Doc   =   Wapp.documents.Add   
              Wapp.Selection.TypeText   GetDocText   
              Doc.SaveAs   "c:\temp.doc"   
              '************************************************   
      '}   
      GoTo   finally   
      catch:   
      '{   
              GetDocText   =   ""   
      '}   
      finally:   
      '{   
              '如果文档对象不为空,那么说明打开了文档,关闭它,并销毁文档对象   
              If   Not   (Doc   Is   Nothing)   Then   Doc.Close:   Set   Doc   =   Nothing   
              '如果word   application对象不为空,那么说明创建了word对象,   
              '退出它,并销毁对象   
              If   Not   (Wapp   Is   Nothing)   Then   Wapp.Quit:   Set   Wapp   =   Nothing   
      '}   
        
      End   Function   
      
      
      祥情请看:http://www.80diy.com/home/20060213/13/4553099.html
      

  6.   

    CreateObject("Word.Application")
    这还是启动了WORD
    Wapp.Visble=True
    就知道了
      

  7.   

    可以用写字板打开 再另存为txt吧
      

  8.   

    chenjl1031 提供的例子中还是使用了WORD的控件。CreateObject("Word.Application")  
      

  9.   

    是啊,看来只有在写字板中作文章。第1步:用写字板打开WORD文档;2、扫描写字板文本框并获得文本内容。
      

  10.   

    Sub   SaveAsTextFile()   
              Dim   strDocName   As   String   
              Dim   intPos   As   Integer   
        
              'Find   position   of   extension   in   filename   
              strDocName   =   ActiveDocument.Name   
              intPos   =   InStrRev(strDocName,   ".")   
        
              If   intPos   =   0   Then   
        
                      'If   the   document   has   not   yet   been   saved   
                      'Ask   the   user   to   provide   a   filename   
                      strDocName   =   InputBox("Please   enter   the   name   "   &   _   
                              "of   your   document.")   
              Else   
        
                      'Strip   off   extension   and   add   ".txt"   extension   
                      strDocName   =   Left(strDocName,   intPos   -   1)   
                      strDocName   =   strDocName   &   ".txt"   
              End   If   
        
              'Save   file   with   new   extension   
              ActiveDocument.SaveAs   FileName:=strDocName,   _   
                      FileFormat:=wdFormatText   
      End   Sub   
      

  11.   

    请问ActiveDocument.Name 引用的是哪个控件?