Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Printing a word document
Message
From
08/07/2006 19:03:50
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/07/2006 13:43:03
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01134666
Message ID:
01134727
Views:
22
>>>needing to print a word document without opening word application or showing it in a form or previewing: just sending to the printer. Is it possible?
>>>Thanx in advance
>>
>>Yes and no.
>>Yes:
>>
>>declare long ShellExecute in "shell32.dll" ;
>>	long hwnd, string lpszOp, ;
>>	string lpszFile, string lpszParams, ;
>>    string lpszDir, long nShowCmd
>>lcDocument = "c:\myPath\blah blah.doc"
>>ShellExecute(0,'Print',m.lcDocument,0,0,1)
>>
>>No:
>>OS shows up word anyway.
>>
>>Alternatively if you didn't mean "not using automation" by saying "without opening word application" then you could do it w/o a word showing.
>>
>>oWord = create('word.application')
>>...
>>.PrintOut
>>* quit when it finsihes.
>>
>>Cetin
>
>Hi Cetin,
>I have problem with printout: it returns such an error (1484 if i remember). Can you explain deeper your code, ie with 'myapp.doc'?

Something like:
#include "wdconst.h"
Local oWordDocument
oWordDocument=Createobject("word.application")	&& Create word object
With oWordDocument
  .Options.PrintBackGround = .T.
  .documents.Open(m.lcDocument)
  oWatcher = Createobject('myTimer', oWordDocument)
  .ActiveDocument.PrintOut(.T.)
Endwith
Read Events


Define Class myTimer As Timer
  Interval = 1000
  oWord = .Null.

  Procedure Init
    Lparameters toWord
    This.oWord = toWord
  Endproc

  Procedure Timer
    With This.oWord
      If .BackgroundPrintingStatus > 0 && Wait printing to finish
        Return
      Endif
      For Each oDoc In .documents
        oDoc.Close(wdDoNotSaveChanges)
      Endfor
      oDoc = .Null.
      .Quit(wdDoNotSaveChanges)
    Endwith
    This.Enabled = .F.
    Clear Events
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform