Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
spawning Excel and giving it a Print Command
Can you spawn Excel from an outside program (or command line) and pass it a
filename as a parameter and ask that file be printed without opening Excel? I don't want any operator intervanetion. I want to be able to call Excel from an outside program (c#, .NET Application) and give Excel the filename and a print command as a parameter. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
spawning Excel and giving it a Print Command
"Merdaad" schreef in bericht ... Can you spawn Excel from an outside program (or command line) and pass it a filename as a parameter and ask that file be printed without opening Excel? I don't want any operator intervanetion. I want to be able to call Excel from an outside program (c#, .NET Application) and give Excel the filename and a print command as a parameter. Thanks I think it's not possible to printout a closed file because for printing some data need to be read anyway. However, you can run Excel on the background using a simple VBScript that you can create in Windows Notepad: Dim lResult Dim strFile strFile = InputBox( "Workbook name please..." ) lResult = PrintSheet( strFile ) Private Function PrintSheet( strFileName ) Dim xlApp, xlWbk, xlSht Set xlApp = CreateObject( "Excel.Application" ) Set xlWbk = xlApp.Workbooks.Open( strFileName ) xlApp.Visible = False Set xlSht = xlWbk.Sheets( 1 ) xlSht.Activate ActiveSheet.PrintOut xlWbk.Close xlApp.Quit Set xlSht = Nothing Set xlWbk = Nothing Set xlApp = Nothing End Function 'Save the code as PrintSheet.VBS on your Desktop, double click it and it should work... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
spawning Excel and giving it a Print Command
Thanks. Is it even possible to spawn Excel, pass a filename to it as a
parameter and have it start with the file/worksheet open. That way the operator will only have to press a print button. Thx "moon" wrote: "Merdaad" schreef in bericht ... Can you spawn Excel from an outside program (or command line) and pass it a filename as a parameter and ask that file be printed without opening Excel? I don't want any operator intervanetion. I want to be able to call Excel from an outside program (c#, .NET Application) and give Excel the filename and a print command as a parameter. Thanks I think it's not possible to printout a closed file because for printing some data need to be read anyway. However, you can run Excel on the background using a simple VBScript that you can create in Windows Notepad: Dim lResult Dim strFile strFile = InputBox( "Workbook name please..." ) lResult = PrintSheet( strFile ) Private Function PrintSheet( strFileName ) Dim xlApp, xlWbk, xlSht Set xlApp = CreateObject( "Excel.Application" ) Set xlWbk = xlApp.Workbooks.Open( strFileName ) xlApp.Visible = False Set xlSht = xlWbk.Sheets( 1 ) xlSht.Activate ActiveSheet.PrintOut xlWbk.Close xlApp.Quit Set xlSht = Nothing Set xlWbk = Nothing Set xlApp = Nothing End Function 'Save the code as PrintSheet.VBS on your Desktop, double click it and it should work... |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
spawning Excel and giving it a Print Command
Just set xlApp.Visible to True and remove the lines - ActiveSheet.PrintOut - xlWbk.Close - xlApp.Quit Then Excel should remain open. "Merdaad" schreef in bericht ... Thanks. Is it even possible to spawn Excel, pass a filename to it as a parameter and have it start with the file/worksheet open. That way the operator will only have to press a print button. Thx "moon" wrote: "Merdaad" schreef in bericht ... Can you spawn Excel from an outside program (or command line) and pass it a filename as a parameter and ask that file be printed without opening Excel? I don't want any operator intervanetion. I want to be able to call Excel from an outside program (c#, .NET Application) and give Excel the filename and a print command as a parameter. Thanks I think it's not possible to printout a closed file because for printing some data need to be read anyway. However, you can run Excel on the background using a simple VBScript that you can create in Windows Notepad: Dim lResult Dim strFile strFile = InputBox( "Workbook name please..." ) lResult = PrintSheet( strFile ) Private Function PrintSheet( strFileName ) Dim xlApp, xlWbk, xlSht Set xlApp = CreateObject( "Excel.Application" ) Set xlWbk = xlApp.Workbooks.Open( strFileName ) xlApp.Visible = False Set xlSht = xlWbk.Sheets( 1 ) xlSht.Activate ActiveSheet.PrintOut xlWbk.Close xlApp.Quit Set xlSht = Nothing Set xlWbk = Nothing Set xlApp = Nothing End Function 'Save the code as PrintSheet.VBS on your Desktop, double click it and it should work... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
set area in excel not giving me option to set print area? | Excel Discussion (Misc queries) | |||
Vlookup command not giving the correct result | Excel Worksheet Functions | |||
Print area giving me 1 page per cell | Excel Discussion (Misc queries) | |||
Excel spawning a new window when opening a file | Excel Worksheet Functions | |||
Giving FOCUS to Print Preview | Excel Programming |