Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Print Excel file via VB
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Print Excel file via VB
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
print all worksheets of Excel file to one pdf file | Excel Discussion (Misc queries) | |||
my excel is converting all my print jobs to print to file why? | Excel Discussion (Misc queries) | |||
How do I print from a file created from sending a print to a file | Excel Discussion (Misc queries) | |||
Print to File: In Excel? | Excel Programming | |||
FILE Save As / FILE Print greyed out in Excel | Excel Programming |