Word Object Model...?
| From: | Gustav Wiberg | Date: | Mon, 08 Oct 2007 14:53:00 +0000 |
| Subject: | Word Object Model...? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-28530@lists.php.net to get a copy of this message | ||
Hi!
Where should I get any reference for Word Object Model for use with PHP. Is Microsofts documentation
the only one available or is does anyone know some word-reference-parameters that are available for
PHP-use... ?
The one I found is:
http://msdn2.microsoft.com/en-us/library/tcyt0y1f(VS.80).aspx
Is there specific in Word that has to been installed for COM+ to work?
Best regards
/Gustav Wiberg
<?php
$word = new COM("word.application");
//To see the version of Microsoft Word, just use $word->Version
echo "I'm using MS Word {$word->Version}";
//It's better to keep Word invisible
$word->Visible = true;
//Creating new document
$word->Documents->Add();
//Setting 2 inches margin on the both sides
$word->Selection->PageSetup->LeftMargin = '2"';
$word->Selection->PageSetup->RightMargin = '2"';
//Setup the font
$word->Selection->Font->Name = 'Verdana';
$word->Selection->Font->Size = 8;
//Write some text
//$word->Selection->TypeText("Hello, universe!");
$word->Selection->Documents[1]->Open("c:\\www\\test.doc");
//Save the document as DOC file
//$word->Documents[0]->SaveAs("test.doc");
//$word->Documents[1]->SaveAs("C:htdocshello2.rtf",6);
// or use: $word->Documents[1]->SaveAs("C:htdocshello2.htm",8); to save as HTML file
//And of course, quit Word
//$word->quit();
//$word->Release();
$word = null;
//Give the user a download link
echo '<a href="hello2.doc">Download file as .doc</a>';
?>