*!* Example of getting a DOCX file, opening it up via 7zip, replacing a few placeholders and re-zipping *!* I normally use bookmarks, but with this it might be a bigger level of complexity. DECLARE INTEGER ShellExecute ; IN SHELL32.DLL ; INTEGER nWinHandle,; STRING cOperation,; STRING cFileName,; STRING cParameters,; STRING cDirectory,; INTEGER nShowWindow SET DEFAULT TO C:\appsvfp_6x\common60\Projects\VFP_to_xlsX\ SET SAFETY off WAIT WINDOW "select template DOcX file to unzip" lcDocXFile = GETFILE("docx") IF FILE(lcDocXFile) lcZipFile = JUSTPATH(lcDocXFile)+"\" + juststem(lcDocXFile) + ".zip" COPY File (lcDocXFile) to (lcZipFile) ELSE WAIT WINDOW "No DOCx slected -- bye" RETURN ENDIF lcOutputDir = "C:\temp\wcAttachments\_DocX"+SYS(2015)+"\" lcZipCommandToExtract = 'x ' + lcZipFile +" -o"+lcOutputDir lSuccess=ShellExecute(0,'open','7z.exe',lcZipCommandToExtract,'',1) WAIT WINDOW "Let's hesitate a few seconds to allow the file operations to complete" TIMEOUT 3 *!* OK, Let's Now maniplute the word\document.xml file and swap and a few placeholders lcDocumentXML = lcOutputDir + "word\document.xml" strDocumentXML = FileToStr(lcDocumentXML) strDocumentXML = STRTRAN(strDocumentXML,"*CAR_ID*","000001, jkt-001") strDocumentXML = STRTRAN(strDocumentXML,"*date_open*",MDY(DATE())) strDocumentXML = STRTRAN(strDocumentXML,"*cIssueCode*","TEST ZIP DOCX process") strDocumentXML = STRTRAN(strDocumentXML,"*cAsssignee*","Kevin V. Emmrich") *** Copy back to xml file STRTOFILE(strDocumentXML,lcDocumentXML) WAIT WINDOW "Let's hesitate a little " TIMEOUT 1 *** Now lets zip it back up FolderToArchive = lcOutputDir FileToOutput = "c:\temp\wcAttachments\NewDocXFile.zip" lcZipCommandToArchive = 'a ' + FileToOutput +" "+FolderToArchive+"*" lSuccess=ShellExecute(0,'open','7z.exe',lcZipCommandToArchive,'',1) *** of course then we rename the file back to DOCX
*******************************************************