Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Word automation from Visual Foxpro:  How to set printer

Posted on 2011-05-13
7
Medium Priority
?
272 Views
Last Modified: 2016-02-22
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
0
Comment
Question by:peterduck
  • 3
  • 2
6 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35754503
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35754552
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
 

Accepted Solution

by:
peterduck earned 0 total points
ID: 35754757
Problem solved !  I was being stupid:

The active printer belongs to oWord, not oDocument.

oWord.activeprinter = thisform.printer  works ok

Nick
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35754912
I should have spotted that. Duh!
0
 

Author Comment

by:peterduck
ID: 35754958
I've been there lots of times - and thanks anyway,

Nick
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41475162
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question