[PHP-WIN] MS Word COM Object formatting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a situation where I am storing Bios in SQL Server that contain HTML
tags so they display correctly on Web Pages and on our company Portal.
They recently decided that they want to have these Bios available in MS
Word format.  Because of the dynamic nature of the Bios and the importance
of them, they have to be created on the fly.

I have been somewhat successful in that I can create the MS Word file and
place the text in it.  But unfortunately I am having trouble changing the
font attributes.  I have been recording macros while performing the
changes I want to make and then opening them in the VB Editor to get the
syntax.  When I incorporate them into my PHP script they have no effect.

My question is how can I change the font styling using the MS Word COM
object from PHP?  ...or better yet...is there a way to have the HTML
styling "carry over" to the MS Word Doc?

VB Code from Macro:

Selection.WholeStory
Selection.Font.Name = "Arial"


My PHP Code (I left out the code to pull the $bio from the database):

$bio = str_replace("?","'",$bio);
$bio = strip_tags($bio);
}


$word=new COM("Word.Application") or die("Cannot start word for you");
$word->visible =0 ;
$word->Documents->Add();
$word->Selection->Typetext("$bio");
$word->Selection->WholeStory;
$word->Selection->Font->Name("Arial");
$word->Documents[1]->SaveAs("testwrite.doc");
$word->Quit();



Thanks,
Ron





-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux