ppt.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * 创建:信呼开发团队(雨中磐石)
  3. * 主页;http://www.rockoa.com/
  4. * ppt文件转html程序
  5. * 使用:cscript //nologo xls.js //T:500 D:\a.doc
  6. * var fso = new ActiveXObject("Scripting.FileSystemObject");
  7. */
  8. WScript.Echo("start...");
  9. function getarr(caa){
  10. var s='';
  11. for(var a in caa)s+=' @@ '+a+'=>'+caa[a]+'';
  12. return s;
  13. }
  14. function gotourl(url){
  15. var xml = new ActiveXObject("MSXML2.XMLHTTP");
  16. xml.open("GET",url,false);
  17. xml.send();
  18. WScript.Echo("goto:"+url+"");
  19. }
  20. var files = WScript.Arguments;
  21. var docfile = files(0);
  22. WScript.Echo(docfile);
  23. var path = docfile.substr(0, docfile.lastIndexOf('.'));
  24. var isok = 2;
  25. var Obj = false;
  26. try{
  27. Obj = new ActiveXObject("Powerpoint.Application");
  28. Obj.Visible = true; //转化必须可视
  29. Obj.DisplayAlerts = false;
  30. var doc = Obj.Presentations.Open(docfile);
  31. }catch(e){
  32. Obj = false;
  33. WScript.Echo("Error:"+getarr(e)+"");
  34. }
  35. if(Obj){
  36. var pdfpath = ""+path+".pdf";
  37. var fso = new ActiveXObject("Scripting.FileSystemObject");
  38. if(fso.FileExists(pdfpath))fso.DeleteFile(pdfpath);
  39. fso = false;
  40. try{
  41. doc.SaveAs(pdfpath,32, true); //32的
  42. WScript.Echo("isuccess");
  43. isok = 1;
  44. }catch(e){
  45. WScript.Echo("Error:"+getarr(e)+"");
  46. }
  47. doc.Close();
  48. Obj.Quit();
  49. }
  50. var yurl = files(1);
  51. if(isok>0 && yurl)gotourl(yurl+'&status='+isok+'');
  52. WScript.Quit(0);