I'm running into a problem with my php application. I'm building up a service application which should be connected to our ERP ( selectline ).
But I can't get to create a COM Object. This code:
<?PHP
error_reporting(E_ALL);
session_start();
date_default_timezone_set('Europe/Zurich');
echo time();
$obj = new COM("fd6c8b29-e936-4a61-8da6-b0c12ad3ba00") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";
?>
Returns me:
Fatal error: in C:\xampp\htdocs\com.php on line 21
I got two environments:
Server 2008 R2 + Xampp v3.1.0 |PHP 5.4.7
Server 2012 R2 + Xampp v3.1.0 | PHP 5.4.7
I had to add the php_com_dotnet.dll in the php.ini because I had COM class not found before.
Due to the fact I'm complete new to COM I have no idea where to search for the failure.
May you guys can help me out.
Thanks in advance
I changed my code a bit:
try {
$obj = new COM("word.application") or die("Unable to instantiate Word");
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
Now I get:
Failed to create COM object `word.application': Invalid Syntax
I don't get what is wrong. According to this article http://www.php.net/manual/en/class.com.php there is no need for additional parameters, right?
Make sure to set the correct COM permission to "This User".
I hope I save lots and lots of hours of headaches to some of you :)
PHP Setup
extension=php_com_dotnet.dll
Usage
<?php
try {
$word = new COM("word.application");
} catch (Exception $ex) {
echo $ex->getMessage();
exit;
}
$word->Screenupdating = true;
$word->WindowState = 2;
$word->Visible = 0;
$word->CheckLanguage = false;
$word->Options->Overtype = false;
$word->Options->SaveInterval = 0;
$word->Assistant->Visible = false;
$word->DisplayAlerts = false;
// Do fancy stuff...
// Close word
$word->Quit();
$word = null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With