Click here to Skip to main content
15,557,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually I am using below code to print the excel file .
But i am not able to print all worksheets .


VB
Dim oProcess As New System.Diagnostics.Process
With oProcess.StartInfo
  .CreateNoWindow = True
  .WindowStyle = ProcessWindowStyle.Hidden
  .Verb = "print"
  .UseShellExecute = True
  .FileName = Application.StartupPath + "\tempcashDeposit.xlsx"
End With

xlWorkBook.Close(SaveChanges:=True)
oProcess.Start()
oProcess.Dispose()
oProcess.Close()
Posted
Updated 13-Aug-15 1:38am
v2

At this moment i see that you're using Interop. Why don't you use Excel's methods?

VB
For Each wsh As Worksheet in xlWorkBook.Worksheets
    wsh.PrintOut
Next 


Worksheet.PrintOut Method [^]
For Each...Next Statement (Visual Basic)[^]
 
Share this answer
 
You cannot simply start a process and use it as xlWorkBook in vbs style. From vb.net you would need setup com interop yourself. But... I published a helper for use with ExcelDataReader, called ExelDataReaderHelper. It makes it even more easy to read from excel files. without the need for com interop. Maybe this can help you out. The example is in c# but the package should work fine with vb.net also.

Additional Helper Methods to the ExcelDataReader Package[^]

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900