View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
KitCaz KitCaz is offline
external usenet poster
 
Posts: 2
Default Print Excel file via VB

Hey, your code snippet worked great. Thank you!

Can you speculate on similar code to print a PowerPoint (.mpp) file? (last
one :)).

Thanks in advance,

Chris

"arunkhemlai" wrote:

I have no vb to test, it works for vb-script; try it yourself.

Dim ExcelApp, ExcelWb

Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWb = ExcelApp.WorkBooks.Open("yourfile.xls")
ExcelWb.WorkSheets.PrintOut
ExcelApp.Quit
Set ExcelObj = Nothing



"KitCaz" wrote:

Recently someone provided some succinct code to print Word documents from VB
code. Can someone provide similar code for printing Excel files?

e.g. Word code:

Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "c:\yourfile.doc"
WordObj.PrintOut Background:=False, Copies:=1
WordObj.Quit
Set WordObj = Nothing