drfu29983 2013-10-28 18:14
浏览 405

php com ms word Documents-> Open()无效

I'm generating MS Word .docx files with COM (Component Object Model) using Find/Replace method on a template document.

The problem: it works fine on my PC, but I can't get it work on the production PC!! I have same configuration on both computers.

First I instantiate a COM object $word = new COM('word.application'); echo "Loaded Word, version {$word->Version} "; says 12.0. So I deduce everything is ok so far. Something goes wrong on $word->Documents->Open("c:\\test.docx"); command. It look's like whatever I put between the brackets is not passed through. Just the same as I'd put $word->Documents->Open(" ");

On the next line: $word->Selection->Find->ClearFormatting(); I get the error message: "Trying to get property of non-object " and a fatal error after that. It looks like an empty string is passed in Documents->Open() and the COM object is destroyed.

I tried relative, absolute paths, backslashes, double slashes... and it look's like it doesn't have anything to do with it. As well the command $word->visible = 1; doesn't bring word up.

There is more or less the same configuration on both PCs : 1st PC: - win7 Ultimate,32-bit, ms Word 7, same WAMP version 2nd PC: - win7 Professional,32-bit, ms Word 7, same WAMP version

I tried macros on the second PC, like: Documents.Open FileName:="test.docx" etc. and it works fine. I have no idea what is different on the second PC and what could possibly be the cause.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能