Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatin Word...Asynchronous, synchronous??? 2

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
0
0
US
Hello,
I have an MSWord problem. I've had this problem a couple of times in the past, and have never arrived at a good solution. The other times I think I just McGiver'd it. This time I can't do that.
Here's what I have:
wApp=createobject('word.application')
wapp.documents.open('mypath\myfile')
wapp.printout
wapp.quit
release wapp

Pretty simple, huh?
Anyway, the problem is (as you may have guessed) that FoxPro tries to quit Word before it's finished printing and you get that error message that asks you if you really want to quit, because if you do, you'll cancel your print job.
So, how do I prevent FoxPro from closing Word before Word is finished printing??? I keep seeing this "asynchronous" word here and there and don't know if that applies.
Thanking you in advance.
-Mike
 
Hupp!! I got it.
I use the application.backgroundprintstatus.
Works fine.
Thanks anyway.
-Mike
 
alternitvly you can use

wApp=createobject('word.application')
wapp.documents.open('mypath\myfile')
wapp.printout(.f.)
wapp.quit
release wapp
 
Or another way would be:
Code:
DECLARE INTEGER ShellExecute IN "Shell32.dll" ;
INTEGER, STRING, STRING, STRING, STRING, INTEGER
=ShellExecute(0,"open", "d:\temp\myword.doc","","",0)
=ShellExecute(0,"print", "d:\temp\myword.doc","","",0)

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hawkieboy...great info, thanks!
gagnon: interesting, not sure I understand it, but interesting, thanks!!
-Mike
 

gagnon: interesting, not sure I understand it, but interesting, thanks!!

Its an API call to print out a Word document without having to Automate Word.

In your case if you just want to print the document you would use:
Code:
DECLARE INTEGER ShellExecute IN "Shell32.dll" ;
INTEGER, STRING, STRING, STRING, STRING, INTEGER
=ShellExecute(0,"print", "c:\hello.doc","","",0)
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I got it. Excellent! Thanks again.
-Mike
 
mgagnon

I used you above code using =ShellExecute. Works great, but it prints to your local printer. Is there a way to change your printer?

Thanks.
 

FAQ184-2977

This requires Window scripting 5.6 to be installed on the computer.

Code:
oNet = CREATEOBJECT("WScript.Network")
oNet.SetDefaultPrinter("\\slp_nt_termserv\Panasonic Printer")

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top