Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

macro variable scope?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nik - 04 Jan 2005 09:34 GMT
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?
Jonathan West - 04 Jan 2005 10:02 GMT
> Hello,
>
[quoted text clipped - 8 lines]
> 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.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Nik - 04 Jan 2005 10:53 GMT
> 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 ;-)
Peter - 05 Jan 2005 19:30 GMT
> 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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.