duai4512 2016-09-14 05:17
浏览 286

如何使用消息'参数0:类型不匹配来解决异常'com_exception'。 '在COM中(“Word.Application”)

I have try catch statement in php, but after running I am getting some error saying

exception 'com_exception' with message 'Parameter 0: Type mismatch. ' in C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\AutomationDocumentation\doccreation.php:218 Stack trace: #0 C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\AutomationDocumentation\doccreation.php(218): variant->Open(false) #1 {main}

below is my code:

try{
   $word = new COM("Word.Application") or die ("Could not initialise Object.");
   // set it to 1 to see the MS Word window (the actual opening of the document)
   $word->Visible = 0;
   echo "Anish";
   $path=realpath("C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\AutomationDocumentation/$releasedoc/$releasedocfile.docx");
   //echo $path;
   // recommend to set to 0, disables alerts like "Do you want MS Word to be the default .. etc"
   $word->DisplayAlerts = 0;
   // open the word 2007-2013 document 
   $word->Documents->Open($path);
   $a="hello";
   // convert word 2007-2013 to PDF
  $word->ActiveDocument->ExportAsFixedFormat("C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\AutomationDocumentation\$created/$mainfolder/$releasedoc/$releasedocfile.pdf", 17, false, 0, 0, 0, 0, 7, true, true, 2, true, true, false);
   // quit the Word process
   $word->Quit(false);
   // clean up
   unset($word);
}catch(Exception $e){
   echo $e;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多