|
Posted by Patrick on 07/30/07 09:23
gosha bine a écrit :
> Patrick wrote:
>> Hello,
>>
>> I try to create a Word document from PHP.
>>
>> I use the COM class to create the Word object and the methods and
>> properties of the object ot access it.
>>
>> No problem until I use the predefined constants of Word as parameter
>> of methods or value of properties : I get an exception in PHP.
>>
>> Here is my code :
>>
>> com_load_typelib("Word.Application");
>> $word = new COM("Word.Application");
>> $doc = $word->Documents->Add();
>> $doc->Activate();
>> $doc->Select();
>> $word->ActiveDocument->PageSetup->Orientation = wdOrientLandscape;
>> $word->Selection->TypeText("CRs monitoring for product $product");
>> $doc->Close(wdDoNotSaveChanges);
>> $word->Quit();
>> $word = null;
>> unset($word);
>>
>> This code produce an exception with the following error message :
>> "Parameter 0: Le type ne correspond pas" (the type does not
>> correspond) on the line with the constant "wdOrientLandscape".
>>
>> I tried with and without the instruction "com_load_typelib", the
>> result is the same !
>>
>> Could you explain what I must do to use OLE in PHP ?
>>
>> For information I use Win XP, Office XP and PHP 5.2.3.
>>
>> Thanks by advance.
>>
>> Patrick
>
> What does it say if you do
>
> com_load_typelib("Word.Application");
> print_r(preg_grep('/^wd/',
> array_keys(get_defined_constants())));
>
The first time I execute it, I got :
Array
(
[1032] => wdNoMailSystem
[1033] => wdMAPI
[1034] => wdPowerTalk
[1035] => wdMAPIandPowerTalk
[1036] => wdNormalTemplate
[1037] => wdGlobalTemplate
[1038] => wdAttachedTemplate
[1039] => wdContinueDisabled
[1040] => wdResetList
[1041] => wdContinueList
[1042] => wdIMEModeNoControl
.....
)
and I have no error in Word but from the second execution, I got only
Array
(
)
and Word raise the exception.
I think that the library is already loaded (so it is not reloaded) but
not seen in Word.
Patrick
Navigation:
[Reply to this message]
|