help wordconvert

Title

wordconvert -- wordconvert calls PowerShell to transfer files among several types in windows system. It supports windows system with a PowerShell.

Syntax

wordconvert old_file.extension new_file.extension, [options]

Description

wordconvert calls PowerShell and MS Word to transfer file among several types. The types of both old file and new file can be identified by their extensions.
Extensions for both the old file and the new file can be .rtf, .doc, .dot, .docx, .pdf and .xps. .docx requires MS Word 2007 or above, and converting .pdf to other types requires MS Word 2013 or above.
If you meet some bugs when converting files, be sure that other applications such as WPS or a lower version of office have no impact, or you can contact us by email.

wordconvert requires your computer has already installed PowerShell and MS Word.

Before you run wordconvert, you must set your PowerShell as following:

(1)Set Powershell’s ExecutionPolicy to be remotesigned. There are 4 steps as following, and you can also google the website for more visual directions.

a)From the command line, key in “Powershell” to find the program.

b)Right click the program line, then choose “run as Administrator”. Then a blue window appears with white cursor blinking, which prompts a command line to be inputted.

c)Key in set-ExecutionPolicy RemoteSigned and then return.

d)At the prompt line, key in Y and then press Enter.

(2)Add the path where PowerShell is located to the environment variable path:

a)Find where your PowerShell is located. Suppose and normally, your PowerShell is located at the following folder: “C:\Windows\System32\WindowsPowerShell\v1.0”

b)Right click My Computer, and then click “Properties” at the pop-up menu.

c)A larger Dialog box appears. Go to the bottom line of North-West corner to click on “Advanced System Settings”.

d)At the new “System Property” dialog box, click on “Environmental Variable”, which is at the South-East corner.

e)A new dialog box called “Environmental Variable” appears. The box is divided into two panels. The lower panel is called “System Variable”. You are required to double click on the “path”
line in the lower panel, then you will see a new dialog box called “Edit Environmental Variable”.

f)Add Powershell’s directory to the list and then save.

Options for wordconvert

replace permits to overwrite an existing file.

encoding(string) the default encoding of PowerShell is ASCII, when you are using Stata version 14.0 or higher and the name or the location of the file you want to transfer contains characters that
are not ASCII characters, you need to use the encoding option. Suppose that the file you are transferring is “文档.docx”, with a Chinese file name “文档”, which can be downloaded with the following
command:

. copy "http://202.114.234.173:8669/appres/COMMONUSE/%E6%96%87%E6%A1%A3.docx" "文档.docx", replace

In order to be recognized by PowerShell, you need to use wordconvert with the encoding option as following, which transfers the utf8 Chinese characters to gb2312:

. wordconvert "文档.docx" "文档.rtf", replace encoding(gb2312)

The encoding() option can only be used in Stata version 14.0 or higher. To learn more about encoding, see encodings.

Example

//202.114.234.173:8669/appres/COMMONUSE/file.rtf" "file.rtf", replace"'

`"wordconvert "file.rtf" "file.docx", replace"'

//202.114.234.173:8669/appres/COMMONUSE/%E6%96%87%E6%A1%A3.docx" "文档.docx", replace"'

`"wordconvert "文档.docx" "文档.rtf", replace encoding(gb2312)"'

Author

Chuntao LI

China Stata Club(爬虫俱乐部)

Wuhan, China

chtl@zuel.edu.cn

Yuan XUE

China Stata Club(爬虫俱乐部)

Wuhan, China

xueyuan19920310@163.com