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

Check the Excel VBE Help for the PrintOut method. Note that it's used on
the Range object. You may also want to read the PrintArea method.

This is Excel VBA code (which is what this newsgroup deals with). But it
will also work in VB6 if you declare an Excel.Application object (like the
Word.Application object in your code); with a reference to the Excel object
model and an Excel object, VB6 code will look almost identical to VBA.
(VB.Net is a different animal that I am not familiar with.)
Ed

"KitCaz" wrote in message
...
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