Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Automation Printing - Suppress Dialog?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01216832
Message ID:
01217431
Vues:
67
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   
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform