ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: Impression Fichiers   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

ven. 17 février 2012, 15h39
Gregory
atoutfox.public.association

Re: Impression Fichiers


Ici, c'est bien imprime, mais word donne une erreur a la fin

Mais ce bout de code imprimera un doc ou docx



lcprinter = 'Bullzip PDF Printer'
filename = 'd:\tmp\1.docx'

= PrintWordDoc(m.filename, m.lcprinter )



function PrintWordDoc(filename, printername)

local wordObj, printerOld

=WindowsPrinter Set(m.printername, @m.printerOld)
wordObj = createObject( 'Word.Application')

=m.wordObj.Documents.Open(filename, , .t.)

#define wdDialogFilePrint 88

with m.wordObj.ActiveDocument.Application.Dialogs(wdDialogFilePrint)
.Printer = m.PrinterName
.numcopies = 1
.Execute()
endwith

declare Sleep in Win32api integer

with m.wordObj.Application
do while !empty(.BackgroundPrintingStatus)
=sleep(100)
enddo
endwith

#define wdDoNotSaveChanges 0
=m.wordObj.Quit(wdDoNotSaveChanges)
wordObj= null

=WindowsPrinter Set(m.printerOld)
endfunc


function WindowsPrinter Set(PrinterNew, PrinterOld)

local success
success = .t.

PrinterOld = WindowsPrinter Get()

if( lower(m.PrinterOld) <> lower(m.PrinterNew) )

try
if( empty(SetDefaultPrinter(m.PrinterNew)) )
assert .f.
success = .f.
endif

catch
assert .f.
success = .f.
endtry

endif

return m.success

endfunc

function WindowsPrinter Get()
return set('Printer', 2)
endfunc

function SetDefaultPrinter(pPrinterName)

local ReturnValue

try
declare Long SetDefaultPrinter In WINSPOOL.DRV ;
String pPrinterName

ReturnValue = SetDefaultPrinter (m.pPrinterName)

catch
assert .f.
ReturnValue = 0

endtry

return m.ReturnValue

endfunc



Gregory

"luckyagi" wrote in message news:jhlmoh$1lmr$1@news.niouzes.net...

Merci.

Cependant, j'ai adapté le code mais le document Word sélectionné par exemple ne s'imprime toujours pas.


Permalink : http://www.atoutfox.org/nntp.asp?ID=0000008264
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3