Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
KC KC is offline
external usenet poster
 
Posts: 27
Default How can i batch convert a bunch of DOCX and DOC files into plain t

Hi there, I would like to convert a bunch of DOCX and DOC files to text
format form the command line. Does MS Office have any such batch conversion
tools? If not, what are my options?

Thanks,
- KC.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How can i batch convert a bunch of DOCX and DOC files into plain t

You cannot do it from the command line without the aid of some third party
converter that can handle both formats, but you can from a Word macro. I
posted a version of the following yesterday for another user who wanted to
save a batch as HTML. This version will save as Windows Text format. There
are however other text formats, which may be better suited to your
requirements.

wdFormatDOSText Microsoft DOS text format.
wdFormatDOSTextLineBreaks Microsoft DOS text with line breaks preserved.
wdFormatEncodedText Encoded text format.
wdFormatText Microsoft Windows text format.
wdFormatTextLineBreaks Windows text format with line breaks
preserved.
wdFormatUnicodeText Unicode text format.

Replace as necessary for FileFormat:=wdFormatText
http://www.gmayor.com/installing_macro.htm

Sub SaveAllAsTXT()
Dim strFileName As String
Dim strDocName() As String
Dim strPath As String
Dim oDoc As Document
Dim Response As Long
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show -1 Then
MsgBox "Cancelled By User", , "Save all as Text"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) "\" Then strPath = strPath + "\"
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFileName = Dir$(strPath & "*.doc")
While Len(strFileName) 0
Set oDoc = Documents.Open(strPath & strFileName)
strDocName = Split(ActiveDocument.FullName, ".")
If ActiveDocument.SaveFormat = 0 Or _
ActiveDocument.SaveFormat = 12 Then
ActiveDocument.SaveAs _
FileName:=strDocName(0) & ".txt", _
FileFormat:=wdFormatText
End If
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


KC wrote:
Hi there, I would like to convert a bunch of DOCX and DOC files to
text format form the command line. Does MS Office have any such batch
conversion tools? If not, what are my options?

Thanks,
- KC.



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Steve Yandl[_2_] Steve Yandl[_2_] is offline
external usenet poster
 
Posts: 4
Default How can i batch convert a bunch of DOCX and DOC files into plain t

KC,

You can do something similar to what Graham Mayor describes with a vbScript
file rather than VBA from Word. As a rule, it makes more sense to do what
Graham described. The one situation where I'd consider the vbScript
approach would be if you wanted to be able to use 'SendTo' from the Windows
Explorer context menu to send a folder for processing (or drag and drop into
a shortcut to the scriipt) or you wanted to be able to type in the name of
the folder as part of the command line and have all the docx and doc files
processed. In those cases, you would be able to take advantage of the
Wscript arguments collection through script.

Is there a particular reason why you wanted to be able to do the conversion
from a command line?


Steve Yandl



"KC" wrote in message
...
Hi there, I would like to convert a bunch of DOCX and DOC files to text
format form the command line. Does MS Office have any such batch
conversion
tools? If not, what are my options?

Thanks,
- KC.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to batch convert Wordperfect 12 files to Windows Vista MSWord Ghujiol Microsoft Word Help 1 November 2nd 08 10:05 AM
How can I convert a batch of .wpd files to Word 2007 files? SPW New Users 3 July 15th 08 05:10 AM
Can I batch convert files to word? Raroboy Microsoft Word Help 1 December 11th 07 05:49 AM
Batch Conversion From .doc to .docx? RichD Microsoft Word Help 6 September 13th 07 04:46 PM


All times are GMT +1. The time now is 06:10 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"