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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 12:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com