WinBatch Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: troya2od on July 02, 2013, 07:34:55 am

Title: OLE and Word 2010
Post by: troya2od on July 02, 2013, 07:34:55 am
I have a few thousand files that I need to convert from .doc to .docx and to .txt.

When using objDoc.SaveAs(ProcessedFile) with the file extension  .txt the file is saved with the .txt extension but is still in the .doc format. The .docx output extension throws a 1261: Ole: Exception.

Obviously I am missing a file format parameter. Can someone point me to the file format values and usage syntax?

TIA
Troy
Title: Re: OLE and Word 2010
Post by: Deana on July 02, 2013, 07:56:31 am
The Word SaveAs method has a number of optional parameters. One being the FileFormat parameter: http://msdn.microsoft.com/en-us/library/office/bb221597(v=office.12).aspx, the value specific should be one of the wdSaveFormat constants, defined here: http://msdn.microsoft.com/en-us/library/office/bb238158(v=office.12).aspx. In your case the value2 for wdFormatText (Microsoft Windows text format).

Reference: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~Word+Word~SaveAs~HTML.txt