Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation Printing - Suppress Dialog?
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01216832
Message ID:
01217431
Views:
68
Sure, the application is an automated process that takes a Word doc and converts it to a PostScript file, then uses GhostScript to convert it to a PDF. It's important that no dialogs stop it along the way. Here's the basic code.
*--Note: GhostScript doesn't like long filenames. 
lcPsFile = ADDBS(JUSTPATH(SYS(16,0))) + "PsFiles\" + SYS(3) + ".ps"

*--Use Word Automation to open the file, and print it to the PostScript file.
#include "wdconst.h"
Local oWord
oWord=Createobject("word.application")
oWord.documents.Open(tcDocFile)
oWord.DisplayAlerts = 0

*--Don't set the printer unless we have to, as it can take a few seconds.
IF ! "Generic PostScript Printer" $ oWord.ActivePrinter
  oWord.ActivePrinter = "Generic PostScript Printer"
ENDIF 

*--NOTE: Oddly enough if the first parm is set to .T. (background printing)
*--word will prompt when a document has information outside of the margins. 
oWord.ActiveDocument.PrintOut(.F.,,, lcPsFile)

*--Close the document and Word.
oWord.Documents(1).Close(wdDoNotSaveChanges)
oWord.Quit(wdDoNotSaveChanges)

*--Now call the GhostScript function that converts the PS file to PDF.
DO Ps2Pdf WITH lcPsFile   
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform