• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1136
  • Last Modified:

Print a word document in Visual Foxpro

>Using the following code my word doc prints in VFP
>
>DECLARE INTEGER ShellExecute ;
>IN SHELL32.DLL ;
>INTEGER nWinHandle,;
>STRING cOperation,;
>STRING cFileName,;
>STRING cParameters,;
>STRING cDirectory,;
>INTEGER nShowWindow
>? ShellExecute(0,"print","c:\what.doc","","",0)
>
>But I get a message
>
>The margins of section 1 are outside the printable area of the page - do you want to continue?
>
>If I say yes it prints fine - how can I stop this message coming up?
0
gaa18
Asked:
gaa18
1 Solution
 
pcelbaCommented:
ShellExecute target is outside the VFP scope...
Could you try Word automation instead of the ShellExecute?
ow = CREATEOBJECT('Word.application')
ow.Visible = .t.
ow.Documents.Open('c:\what.doc')
ow.ActiveDocument.PrintOut()
ow.quit

Open in new window

Also you may try to play with the  ow.DisplayAlerts setting. Allowed values are 0, -1, -2, the 0 value should suppress alerts.

More info about Word automation: http://fox.wikis.com/wc.dll?Wiki~AutomationExamples
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now