macro variable scope?

N

Nik

Hello,

I have a macro that automatically prints documents by settings the
activeprinter and then calling printout and this macro is executed from
the command line with the /m switch.

I have a problem, however when executing several instances
simultaneously using Java threads - the documents can end up at the
wrong printers!

What is the scope of macro variables? Is it possible that they are
common and running the macro simultaneously might overwrite the values?
 
J

Jonathan West

Nik said:
Hello,

I have a macro that automatically prints documents by settings the
activeprinter and then calling printout and this macro is executed from
the command line with the /m switch.

I have a problem, however when executing several instances
simultaneously using Java threads - the documents can end up at the
wrong printers!

What is the scope of macro variables? Is it possible that they are
common and running the macro simultaneously might overwrite the values?

Hi Nik,

The problem is probably not the scope of the variables, but rather of the
fact that changing the ActivePrinter property changes the system default
printer, and so the default printer may be changed by a competing thread
before another thread can successfully execute the PrintOut method.

Word is an awfully large program to be attempting to run multiple instances
simultaneously. I would recommend that you find a way of having the Java
threads chare a single instance of Wor, perhaps be passing the print jobs to
a single queue which then handles control of Word.
 
N

Nik

Word is an awfully large program to be attempting to run multiple instances
simultaneously. I would recommend that you find a way of having the Java
threads chare a single instance of Wor, perhaps be passing the print jobs to
a single queue which then handles control of Word.

Yes, I'm leaning towards that option. OLE could be one option but then
I would have to use a Java-COM bridge and introduce another external
component to the system and it could become a bottleneck if it hangs.

Another option would be to have a single queue and spawn word instances
from there - hardware is cheap nowadays ;-)
 
P

Peter

Yes, I'm leaning towards that option. OLE could be one option but then
I would have to use a Java-COM bridge and introduce another external
component to the system and it could become a bottleneck if it hangs.

If you decide to use OLE, check out jacob, a GPL-licensed Java-COM bridge:
http://sourceforge.net/projects/jacob-project/
I use it extensively for desktop integration with an application that runs as a Java applet.

It can be confusing to use, so be sure to get the examples from
http://geekatwork.net/jacob/

hth,

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top