Page 1 of 2
[solved]converting
Posted: 09 Dec 2013 08:48
by princesstwi
i was wondering does anyone know a batch file code that will convert a windows docx file to a doc file help would be apreciated
Re: converting
Posted: 09 Dec 2013 09:13
by npocmaka_
Here are the Word saving constants ->
http://msdn.microsoft.com/en-us/library ... 39952.aspxYou can check this thread and change the save constant to 0 ->
viewtopic.php?f=3&t=4755
Re: converting
Posted: 09 Dec 2013 09:47
by princesstwi
which is the save constant
note im on a vista
Re: converting
Posted: 09 Dec 2013 09:59
by npocmaka_
The saving constant is passed as the third parameter to the vbscript.Here's ready to use docxToDoc converter .
Should be saved as .batCode: Select all
'>nul 2>&1|| @copy /Y %windir%\System32\doskey.exe .\'.exe >nul
'&&@echo off && cls &&goto :end_vbs
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = FALSE
'Open doc for reading
Set WordDoc = WordApp.Documents.Open(WScript.Arguments.Item(0),true)
'wdFormatText 2
'wdFormatUnicodeText 7
'wdFormatDocument 0
format = CInt(WScript.Arguments.Item(2) )
WordDoc.SaveAs WScript.Arguments.Item(1) ,format
WordDoc.Close()
WScript.Quit
:end_vbs
'& if "%~1" equ "-help" echo %~n0 word_document [ destination ] && exit /b 0
'& if "%~1" equ "" echo word document not given & exit /b 1
'& if not exist "%~f1" echo word document does not exist & exit /b 2
'& if "%~2" equ "" ( set "save_as=%~n1.doc") else ( set "save_as=%~2")
'& if exist "%~f2" del /s /q "%~f2"
'& set "format=0"
'& taskkill /im winword* /f >nul 2>&1
'& cscript /nologo /E:vbscript %~f0 "%~f1" "%save_as%" %format%
'& pause
'& rem del /q .\'.exe
Re: converting
Posted: 09 Dec 2013 10:05
by princesstwi
ok i open it it runs, closes and nothing has changed

Re: converting
Posted: 09 Dec 2013 10:10
by npocmaka_
what parameters did you passed to the script?
it must be called like this:
Code: Select all
call docxToDoc.bat "c:\SomeDoc.docx" "c:\converted.doc"
and this should create a c:\converted.doc file.
Re: converting
Posted: 09 Dec 2013 10:13
by princesstwi
what do you mean it didnt ask me to type anything it just opened ran code real quick and closed
im sorry if im missunderstanding i am new to all batch
Re: converting
Posted: 09 Dec 2013 11:42
by princesstwi
that batch doesnt work for me please help i need to convert some school assignments please help
i am on a windows vista
Re: converting
Posted: 09 Dec 2013 12:36
by npocmaka_
here's a prompting version:
Code: Select all
'>nul 2>&1|| @copy /Y %windir%\System32\doskey.exe .\'.exe >nul
'&&@echo off && cls &&goto :end_vbs
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = FALSE
'Open doc for reading
Set WordDoc = WordApp.Documents.Open(WScript.Arguments.Item(0),true)
'wdFormatText 2
'wdFormatUnicodeText 7
'wdFormatDocument 0
format = CInt(WScript.Arguments.Item(2) )
WordDoc.SaveAs WScript.Arguments.Item(1) ,format
WordDoc.Close()
WScript.Quit
:end_vbs
'& set /p source=Path to the .DOCX file:
'& set /p dest=Destination file:
'& for %%p in ("%source%") do set "source=%%~dpfnxsp"
'& set "dest=%~dp0\%dest%"
'& set "format=0"
'& taskkill /im winword* /f >nul 2>&1
'& cscript /nologo /E:vbscript "%~f0" "%source%" "%dest%" %format%
'& pause
'& rem del /q .\'.exe
Works on my machine .It's vista too...
Re: converting
Posted: 09 Dec 2013 12:47
by princesstwi
so the path to the docx would be if its on the desktop c:\Users\user\Desktop\example.docx
and the path for the converted file would be c:\Users\user\Desktop\converted.doc
Re: converting
Posted: 09 Dec 2013 12:59
by npocmaka_
it will create a doc file in the same directory.If you want to use full path delete this line:
'& set "dest=%~dp0\%dest%"
Probably will be better if you automize the file processing so you'll not have to set destination and source manually.
Re: converting
Posted: 09 Dec 2013 13:08
by princesstwi
path to docx file: C:\Users\user\Desktop\Walking Dead Dialectical Journal.docx
destination file: C:\Users\user\Desktop\it works.doc or i put yes.doc
it comes up with this C:\Users\user\Desktop\docxToDoc.bat<8,1> Microsoft word: command failed
Re: converting
Posted: 09 Dec 2013 14:33
by npocmaka_
I've changed the script to use a short path , to minimize the problems with empty spaces.Use it like this:
path to docx file: C:\Users\user\Desktop\Walking Dead Dialectical Journal.docx
destination file: yes.doc
and it should create yes.doc in the same directory as the batch file.And be sure that the walking dead file exists.
Re: converting
Posted: 10 Dec 2013 08:13
by princesstwi
ok i did what you said and on some it will convert but still be random letters and symbols but others it will come up with this error msg C:\Users\user\Desktop\docxToDoc.bat<8,1> Microsoft word: command failed
i am trying to convert word 2010 to word 2000
Re: converting
Posted: 10 Dec 2013 08:16
by npocmaka_
what symbols? May be some of them could be escaped...