Wenn Ihr mit den Funktion von
CopyText fromTemplate=“Template.rtf“ ToText=“Bericht“
CopyText fromText=“Bericht“ toFile=“&%[TMP]\Bericht.doc“
ein im MS-Word erstellten RTF-Dokument alle Variablen ersetzt und das fix fertige Dokument als *.doc speichert, so ist es eigentlich immer noch ein RTF-File.
Möchte man, dass es ein echtes MS-WORD Dokument wird, und dies gleich noch im neuen *.docx Format, so bedarf es einer Umwandlung.
VBS Script
Function ConvertWordToDocx(DocPath) 'This function is to convert a word.doc document to word.docx file Dim objshell,ParentFolder,BaseName,wordapp,doc,DOCXPath,objselection Set objshell = guixt.CreateObject("scripting.filesystemobject") ParentFolder = objshell.GetParentFolderName(DocPath) 'Get the current folder path BaseName = objshell.GetBaseName(DocPath) 'Get the document name DOCXPath = ParentFolder & "\" & BaseName & ".docx" Set wordapp = guixt.CreateObject("Word.application") Set doc = wordapp.Documents.Open(DocPath) doc.saveas DOCXPath, 16 doc.close wordapp.quit Set objshell = Nothing End Function
Der Aufruf im GuiXt Script erfolgt wie folgt:
callvbs ConvertWordToDocx "&%[TMP]\Bericht.doc"
Netterweise haben mir Herr Bernd Theewen und die Synactive GmbH bei der Erstellung des Scriptes geholfen.