Main goal: create documents (with tables) in Microsoft Word using PHP.
Critical problem encountered: calling:
$document->Range->Find->Execute( ... ); // causes ERROR.
I get information about: line, File, Source: unknown, Description: unknown;
How do I do it (operations in Microsoft Word using PHP):
->Range->InsertAfter( "whatever text needed to be inserted" ); // (success)
$range = $document->Range( x, y );
$Table1 = $range->ConverToTable( wdSeparateByTabs, 1, 2, 30, wdTableFormatNone, false, false, false, false, false, false, false, false, false, wdAutoFitWindow, wdWord9ListBehavior );
// with
wdSeparateByTabs = 1
wdTableFormatNone = 0
wdAutoFitWindow = 2
wdWord9ListBehavior = 1
Despite the fact that i pass number_of_rows=1 (2nd parameter), the table looks as expected.
Next step I want, is to make Word find and replace strings:
$rng = $Table1->Range;
$find = $rng->Find;
$find->Execute( "text to find", false, false, false, false, false, null, wdFindContinue, false, "text to be replaced with", wdReplaceAll, null, null, null, null );
Some system info:
Final thoughts and ideas:
What do I do wrong that calling
->Range->Find->Execute(...);
causes an error?
EDIT: I don't use frameworks, just plan Word, and stock PHP
$word = new COM( 'Word.Application' );
$document = $word->Documents->Add( ); //or
$document = $word->Documents->Open( 'template_file.doc' );