Archive

Posts Tagged ‘Infopath’

Printing Infopath forms

April 25th, 2008 Anuraj P 4 comments

While working in Infopath forms, there may some situations where you may need to Print the InfoPath form. But the problem of Infopath API is that we can’t specify the printer name for printing. Like this one

InfoApp.XDocuments(0).PrintOut()

The printout method doesn’t have any parameters like Printer name or port etc. As a workaround you can export the Infopath document as Word, and print the document using Word API, where you can specify the printer name. To export the Infopath as Word there is no direct method, but you can do export to “MHT”(MHTML Document), and change the extention to “.doc” and using Word.Application you can open it and Print.

'Creating the Infopath application
Dim InfoApp As New InfoPath.Application()
'Opening the Infopath document.
InfoApp.XDocuments.Open("C:\Sample\template.xml")
'Exporting the document as Word(MHT)
InfoApp.XDocuments(0).View.Export("C:\Sample\Samplex.doc", "MHT")

Let me know if you find any other solutions :)