VB.NET open and print an excel file -
i developing simple vb.net desktop app little printing business. has main winform, buttons opening jpg/pdf/word/excel files, open associated program, print file, capture spool job, , charge user being printed, based on printer name, number of pages, size of pages , cost per page. no big deal. hosts machines have win7 os.
when user wants print xls file, want app open excel 2010, opening file selected file dialog. , when excel opens, go directly print dialog, when job finishes load in spool, capture event , kill excel process.
my problem is:
i cant open excel directly going print dialog. excel respond "print" verb. prints default printer. want open , go print dialog. not want print default printer, need allow user select desired printer, pages, copies, etc.
i'm trying following code:
dim openfiledialog1 new openfiledialog() dim filepath string = "" dim startinfo processstartinfo 'openfiledialog1.initialdirectory = "c:\" openfiledialog1.filter = "xls files (*.xls)|*.xls|xlsx files (*.xlsx)|*.xlsx|all files (*.*)|*.*" openfiledialog1.filterindex = 1 openfiledialog1.restoredirectory = true if (dialogresult.ok) = openfiledialog1.showdialog(me) filepath = openfiledialog1.filename else exit sub end if startinfo = new processstartinfo(rutaarchivo) startinfo .filename = filepath .windowstyle = processwindowstyle.normal .verb = "print" .createnowindow = false .useshellexecute = true end try system.diagnostics.process.start(startinfo) catch ex exception msgbox(ex.tostring) end try
ide sharpdevelop 4.3. framework .net 4.0 client profile. os win7.
many :)
ms excel has following command line switches: excel switches
to want, might excel interop
Comments
Post a Comment