Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to batch convert Wordperfect 12 files to Windows Vista MSWord | Microsoft Word Help | |||
How can I convert a batch of .wpd files to Word 2007 files? | New Users | |||
Can I batch convert files to word? | Microsoft Word Help | |||
Batch Conversion From .doc to .docx? | Microsoft Word Help |