小智 3
Juno 有一个新版本 .5.1,它有很多连接到 Word、Excel、FrameMaker、Trados 等的好方法。因此,这是可能的且简单的。像这样的东西:
scope word = new DispatchObject("Word.Application");
scope wDocs = word.get("Documents");
char[] dd = dir ~ r"\";
char[][] docs = GetFilesFromDir(dir ~ r"\", "*." ~ fromType, true);
if (docs.length == 0)
{
info.text = "Did not find any " ~ std.string.toupper(fromType) ~
" files in the directory... \n\nExiting...";
return;
}
foreach(char[] d; docs)
{
scope wDoc = wDocs.call("Open", d);//"Normal", false, 0);
char[] txt = std.path.getName(d); // original file ie. test if it was test.doc
txt ~= ".doc";
if (std.file.exists(txt))
std.file.remove(txt);
wDoc.call("SaveAs",
txt, // FileName
0, // FileFormat wdFormatDOC = 0
false, // LockComments
"", // Password
false, // AddToRecentFiles
"", // WritePassword
false, // ReadOnlyRecommended
false, // EmbedTrueTypeFonts
false, // SaveNativePictureFormat
false, // SaveFormsData
false, // SaveAsAOCELetter
65001, // Encoding 65001 is UTF8
false, // InsertLineBreaks
false, // AllowSubstitutions
0 // LineEnding Const wdCRLF = 0
);
wDoc.call("Close");
}
word.call("Quit");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
386 次 |
| 最近记录: |