Word automation from Visual Foxpro: How to set printer

VFP 9
WORD 2007

We are happily using automation to create WORD docs within VFP and edit or print them.

I am now trying to use Word for multiple mail-merged letters, and need to set the printer for use.

Skeleton code is:

oWord = CREATEOBJECT("Word.Application")
oWord.Visible = .f.

oDocument = oWord.Documents.Open(m.saveAsName)
oRange = oWord.ActiveDocument.Range(0,0)

   word_findreplace( "contact", part_list.contact)

   word_findreplace( "ad1", ad_array[1])
   word_findreplace( "ad2", ad_array[2])

oWord.ActiveDocument.Save()
oDocument.Printout(.T.)
oWord.Quit()

~~~~~~~~~~

We obtain a printer ID with the Foxpro getprinter() method.

~~~~~~~~~~

I fondly imagined that this would work:

oDocument.activeprinter = 'PDFcreator'

but it doesn't, so any ideas welcome.

Nick Cutler
peterduckAsked:
Who is Participating?
 
peterduckConnect With a Mentor Author Commented:
Problem solved !  I was being stupid:

The active printer belongs to oWord, not oDocument.

oWord.activeprinter = thisform.printer  works ok

Nick
0
 
GrahamSkanRetiredCommented:
I suspect that PDFCreator is a virtual printer, you so probably need to supply a file name.

Have you tried it with a physical printer?

0
 
GrahamSkanRetiredCommented:
The fourth parameter of the printout method is named OutPutFileName.

I don't have PDFCreator, and the last time I used Foxpro it was a DOS version, so I can't get you any closer than that.    
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
GrahamSkanRetiredCommented:
I should have spotted that. Duh!
0
 
peterduckAuthor Commented:
I've been there lots of times - and thanks anyway,

Nick
0
 
frankhelkCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.