Reputation: 179
I want to send a Microsoft Word document. But before I send I want to modify its properties like (document title, subject, author, team, manager, company etc.) before sending using PHP.
I cannot use COM as i just learned that the server where this script will run does not have ms office nor am i allowed to install it...so pls give me some other solution.
Thanks
Upvotes: 0
Views: 1088
Reputation: 653
since the problem is with the server environment - I would suggest using OpenOffice and a component phpdocwriter. It is capable of loading Microsoft Office document and manipulate their information.
Hope this helps!
Upvotes: 0
Reputation: 4035
What your looking for is working with Component Object Model in PHP, here is another tutorial
EDIT
Sample code to open new MS Word document:
$word = new COM("word.application") or die ("something went wrong!!");
//open new word document
$word->Documents->Add();
//type text into the document
$word->Selection->TypeText("this is some sample text in the document");
//save document
$word->Documents[1]->SaveAs("newWordDocument.doc");
//close word
$word->Quit();
//free object resources
$word->Release();
$word = null;
Upvotes: 1
Reputation: 179
I am trying to open COM but it just keeps processing .
$word = new COM("word.application") or die("Unable to instantiate application object");
$DocumentPath=$newname; // open up anempty document
$wordDocument = $word->Documents->Open($DocumentPath); >
// clean up
$wordDocument = null; $word->Quit();
$word = null;
if I add this line then it keeps processing.. if i commnet it i cannot open the document...am i doing something wrong
$word->Documents->Open($DocumentPath);
Upvotes: 0