2006-06-08 22:07 [OOo] DOC轉成ODT格式的Script
以下是在Windows底下把Word的DOC格式轉換成OpenOffice Writer的ODT格式,這樣可以方便的執行已存在檔案的格式轉換。
##
| doc2odt1.vbs |
| '*********************************************************** '$Id: doc2odt1.vbs 908 2006-06-08 09:01:48Z jerry $ ' '將DOC檔轉換成ODT檔; 必須傳入完整路徑的檔名 '*********************************************************** dim oArgs, oDoc dim xExt, sURL, sSourceFile, sOutputFile set oArgs = WScript.Arguments if oArgs.Count > 0 then sSourceFile = oArgs(0) end if 'The service manager is always the starting point 'If there is no office running then an office is started up Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager") 'Create the CoreReflection service that is later used to create structs 'Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection") 'Create the Desktop Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop") sExt = right(sSourceFile,4) if (sExt = ".doc") then if InStr(sSourceFile, "") <= 0 then Wscript.echo "參數必須包含路徑" else sOutputFile = left(sSourceFile,len(sSourceFile)-4) & ".odt" sURL = ConvertToUrl(sSourceFile) 'Wscript.echo cFile & "==>" & sURL Set oDoc = objDesktop.loadComponentFromUrl(sURL,"_blank", 0, Array()) sURL = convertToURL(sOutputFile) oDoc.storeAsURL sURL, Array() oDoc.close( True ) end if end if WScript.Quit Function ConvertToUrl(strFile) strFile = Replace(strFile, "", "/") strFile = Replace(strFile, ":", "|") strFile = Replace(strFile, " ", "%20") strFile = "file:///" + strFile ConvertToUrl = strFile End Function |
##
平均分數:0 顆星 投票人數:0 人
我要評分:
我要評分:





