By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

COM and MSWord Automation

P: n/a
Hi there!
I'm trying to automate MSWord in the server side.

For limiting memory usage i'm writing code to make a unique instance
of winword and then calling it from the php page i need.

So far i've used the sleep() function to keep alive the winword
instance but i think it would be better to use com_message_pump and
com_event_sink to take care of the winword process.

Alas when i try the code with com_event_sink function winword get
stuck?

Anyone has already tried something similar and/or has good example of
a winword daemon or similar?

(one example can be at http://netevil.org/)

Thanks
Rob
Sep 2 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a

<ro*******@vodafone.itwrote in message
news:c5**********************************@k7g2000h sd.googlegroups.com...
Hi there!
I'm trying to automate MSWord in the server side.

For limiting memory usage i'm writing code to make a unique instance
of winword and then calling it from the php page i need.

So far i've used the sleep() function to keep alive the winword
instance but i think it would be better to use com_message_pump and
com_event_sink to take care of the winword process.

Alas when i try the code with com_event_sink function winword get
stuck?

Anyone has already tried something similar and/or has good example of
a winword daemon or similar?
uhmmm, 'daemon'? winword? you are mixing linux and windows terms. what's
your config? are you running php on linux and creating the word instance on
a remote windows server, or are you running everything on the same
pc/server - a windows server?

you do realize that php may or may not be running in the same process thread
each time an http request is made, right? are you familiar with
cross-process development in windows?
Sep 2 '08 #2

P: n/a
On 2 Set, 14:46, "Dale" <the....@example.comwrote:
<rob02o...@vodafone.itwrote in message

news:c5**********************************@k7g2000h sd.googlegroups.com...
Hi there!
I'm trying to automate MSWord in the server side.
For limiting memory usage i'm writing code to make a unique instance
of winword and then calling it from the php page i need.
So far i've used the sleep() function to keep alive the winword
instance but i think it would be better to use com_message_pump and
com_event_sink to take care of the winword process.
Alas when i try the code with com_event_sink function winword get
stuck?
Anyone has already tried something similar and/or has good example of
a winword daemon or similar?

uhmmm, 'daemon'? winword? you are mixing linux and windows terms. what's
your config? are you running php on linux and creating the word instance on
a remote windows server, or are you running everything on the same
pc/server - a windows server?

you do realize that php may or may not be running in the same process thread
each time an http request is made, right? are you familiar with
cross-process development in windows?
Hi and thanks for the reply.
Well i'm in a win32 server box, and as 'daemon' yes i was meaning a
service (or something like act as it).
I need to make mailmerge (i know of xml classes but i cant do this
because template are manipulated in clients) on the server and i have
realized that using multiple instance of winword will be a wast of
system resources (CPU, memory...).
What i want to accomplish is to have a php script running the COM
winword instance (for a period ie sleeping for accomplish tasks) and
making call with com_get_active_object.
I was thinking that the best practice would be to use com_message_pump
but i'm not really sure about this?
Thanks!
Rob
Sep 2 '08 #3

P: n/a

<ro*******@vodafone.itwrote in message
news:8b**********************************@l42g2000 hsc.googlegroups.com...
On 2 Set, 14:46, "Dale" <the....@example.comwrote:
><rob02o...@vodafone.itwrote in message

news:c5**********************************@k7g2000 hsd.googlegroups.com...
Hi there!
I'm trying to automate MSWord in the server side.
For limiting memory usage i'm writing code to make a unique instance
of winword and then calling it from the php page i need.
So far i've used the sleep() function to keep alive the winword
instance but i think it would be better to use com_message_pump and
com_event_sink to take care of the winword process.
Alas when i try the code with com_event_sink function winword get
stuck?
Anyone has already tried something similar and/or has good example of
a winword daemon or similar?

uhmmm, 'daemon'? winword? you are mixing linux and windows terms. what's
your config? are you running php on linux and creating the word instance
on
a remote windows server, or are you running everything on the same
pc/server - a windows server?

you do realize that php may or may not be running in the same process
thread
each time an http request is made, right? are you familiar with
cross-process development in windows?

Hi and thanks for the reply.
Well i'm in a win32 server box, and as 'daemon' yes i was meaning a
service (or something like act as it).
I need to make mailmerge (i know of xml classes but i cant do this
because template are manipulated in clients) on the server and i have
realized that using multiple instance of winword will be a wast of
system resources (CPU, memory...).
What i want to accomplish is to have a php script running the COM
winword instance (for a period ie sleeping for accomplish tasks) and
making call with com_get_active_object.
I was thinking that the best practice would be to use com_message_pump
but i'm not really sure about this?
Thanks!
you realize that sharing the *same* instance is going to lead to problems,
right? it is no more a waste of resources to instanciate a new word object
than it is to share a single instance across processes, right? further, it
will save you a headache down the road.

have you thought of simply using xml with the ms workup? save your master
document as xml. close the xml doc. reopen it with word. no difference in
appearance, right? all you have to do is open the xml doc in notepad, or
whatever, and use what you see there as your programmatic guide.
Sep 2 '08 #4

P: n/a
On 2 Set, 17:52, "Dale" <the....@example.comwrote:
<rob02o...@vodafone.itwrote in message

news:8b**********************************@l42g2000 hsc.googlegroups.com...
On 2 Set, 14:46, "Dale" <the....@example.comwrote:
<rob02o...@vodafone.itwrote in message
>news:c5**********************************@k7g2000 hsd.googlegroups.com...
Hi there!
I'm trying to automate MSWord in the server side.
For limiting memory usage i'm writing code to make a unique instance
of winword and then calling it from the php page i need.
So far i've used the sleep() function to keep alive the winword
instance but i think it would be better to use com_message_pump and
com_event_sink to take care of the winword process.
Alas when i try the code with com_event_sink function winword get
stuck?
Anyone has already tried something similar and/or has good example of
a winword daemon or similar?
uhmmm, 'daemon'? winword? you are mixing linux and windows terms. what's
your config? are you running php on linux and creating the word instance
on
a remote windows server, or are you running everything on the same
pc/server - a windows server?
you do realize that php may or may not be running in the same process
thread
each time an http request is made, right? are you familiar with
cross-process development in windows?
Hi and thanks for the reply.
Well i'm in a win32 server box, and as 'daemon' yes i was meaning a
service (or something like act as it).
I need to make mailmerge (i know of xml classes but i cant do this
because template are manipulated in clients) on the server and i have
realized that using multiple instance of winword will be a wast of
system resources (CPU, memory...).
What i want to accomplish is to have a php script running the COM
winword instance (for a period ie sleeping for accomplish tasks) and
making call with com_get_active_object.
I was thinking that the best practice would be to use com_message_pump
but i'm not really sure about this?
Thanks!

you realize that sharing the *same* instance is going to lead to problems,
right? it is no more a waste of resources to instanciate a new word object
than it is to share a single instance across processes, right? further, it
will save you a headache down the road.

have you thought of simply using xml with the ms workup? save your master
document as xml. close the xml doc. reopen it with word. no difference in
appearance, right? all you have to do is open the xml doc in notepad, or
whatever, and use what you see there as your programmatic guide.
I will do some test in inizializing some intances of winword, in fact
the process of do a mailmerge is pretty fast something like 2 minute
each...
It's a good point to think about xml! i just tried to save as docx and
then unzipped... seems a lot to work to get into but i like the idea
(in fact i'm doing xls with PHPExcel and work like a charm)...
Thanks a lot for yours suggestions! A good thread!
Rob
Sep 2 '08 #5

P: n/a

<ro*******@vodafone.itwrote in message
news:b8**********************************@z66g2000 hsc.googlegroups.com...
On 2 Set, 17:52, "Dale" <the....@example.comwrote:
><rob02o...@vodafone.itwrote in message

news:8b**********************************@l42g200 0hsc.googlegroups.com...
On 2 Set, 14:46, "Dale" <the....@example.comwrote:
<rob02o...@vodafone.itwrote in message
>>news:c5**********************************@k7g200 0hsd.googlegroups.com...
Hi there!
I'm trying to automate MSWord in the server side.
For limiting memory usage i'm writing code to make a unique instance
of winword and then calling it from the php page i need.
So far i've used the sleep() function to keep alive the winword
instance but i think it would be better to use com_message_pump and
com_event_sink to take care of the winword process.
Alas when i try the code with com_event_sink function winword get
stuck?
Anyone has already tried something similar and/or has good example
of
a winword daemon or similar?
>uhmmm, 'daemon'? winword? you are mixing linux and windows terms.
what's
your config? are you running php on linux and creating the word
instance
on
a remote windows server, or are you running everything on the same
pc/server - a windows server?
>you do realize that php may or may not be running in the same process
thread
each time an http request is made, right? are you familiar with
cross-process development in windows?
Hi and thanks for the reply.
Well i'm in a win32 server box, and as 'daemon' yes i was meaning a
service (or something like act as it).
I need to make mailmerge (i know of xml classes but i cant do this
because template are manipulated in clients) on the server and i have
realized that using multiple instance of winword will be a wast of
system resources (CPU, memory...).
What i want to accomplish is to have a php script running the COM
winword instance (for a period ie sleeping for accomplish tasks) and
making call with com_get_active_object.
I was thinking that the best practice would be to use com_message_pump
but i'm not really sure about this?
Thanks!

you realize that sharing the *same* instance is going to lead to
problems,
right? it is no more a waste of resources to instanciate a new word
object
than it is to share a single instance across processes, right? further,
it
will save you a headache down the road.

have you thought of simply using xml with the ms workup? save your master
document as xml. close the xml doc. reopen it with word. no difference in
appearance, right? all you have to do is open the xml doc in notepad, or
whatever, and use what you see there as your programmatic guide.

I will do some test in inizializing some intances of winword, in fact
the process of do a mailmerge is pretty fast something like 2 minute
each...
It's a good point to think about xml! i just tried to save as docx and
then unzipped... seems a lot to work to get into but i like the idea
(in fact i'm doing xls with PHPExcel and work like a charm)...
Thanks a lot for yours suggestions! A good thread!

not a problem. best wishes.
Sep 2 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.