Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have an xls file i would like to printout from my application. So far i have found this example for printing in general Process pr = new Process(); pr.StartInfo.FileName = "MyFile.xls"; pr.StartInfo.CreateNoWindow = true; pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Verb = "Print"; pr.Start(); pr.WaitForExit(); pr.Dispose(); this prints good but the problem i would like to hide excel from the user or find an alternative way to print the file, without user being aware of any other processes except printing, any ideas or help i greatly appreciated |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Miran" wrote:
Hi, I have an xls file i would like to printout from my application. So far i have found this example for printing in general Process pr = new Process(); pr.StartInfo.FileName = "MyFile.xls"; pr.StartInfo.CreateNoWindow = true; pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Verb = "Print"; pr.Start(); pr.WaitForExit(); pr.Dispose(); this prints good but the problem i would like to hide excel from the user or find an alternative way to print the file, without user being aware of any other processes except printing, any ideas or help i greatly appreciated You could use COM interop and Excel object model to set Application.Visible to false, open the file you want and print it: using System; using System.Reflection; using Microsoft.Office.Interop.Excel; class XLPrintTest { static void Main() { Application ExcelApp = new Application (); ExcelApp.Visible = false; ExcelApp.DisplayAlerts = false; Workbook WBook = ExcelApp.Workbooks.Open ", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); WBook.PrintOut (Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); WBook.Close (false, Missing.Value, Missing.Value); ExcelApp.Quit (); } } -- urkec |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thx for solving the problem
"urkec" wrote: "Miran" wrote: Hi, I have an xls file i would like to printout from my application. So far i have found this example for printing in general Process pr = new Process(); pr.StartInfo.FileName = "MyFile.xls"; pr.StartInfo.CreateNoWindow = true; pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Verb = "Print"; pr.Start(); pr.WaitForExit(); pr.Dispose(); this prints good but the problem i would like to hide excel from the user or find an alternative way to print the file, without user being aware of any other processes except printing, any ideas or help i greatly appreciated You could use COM interop and Excel object model to set Application.Visible to false, open the file you want and print it: using System; using System.Reflection; using Microsoft.Office.Interop.Excel; class XLPrintTest { static void Main() { Application ExcelApp = new Application (); ExcelApp.Visible = false; ExcelApp.DisplayAlerts = false; Workbook WBook = ExcelApp.Workbooks.Open ", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); WBook.PrintOut (Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); WBook.Close (false, Missing.Value, Missing.Value); ExcelApp.Quit (); } } -- urkec |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
import data from txt file to an existing excel file | Excel Discussion (Misc queries) | |||
How do I add a worksheet to an existing EXCEL file? | Excel Worksheet Functions | |||
Creating a new excel file from an existing file using macro | Excel Programming | |||
Open existing Excel file | Excel Discussion (Misc queries) | |||
Trying to open an existing Excel file in C# | Excel Programming |