Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set area in excel not giving me option to set print area? J Littlebear Excel Discussion (Misc queries) 4 April 23rd 23 09:04 PM
Vlookup command not giving the correct result VKL Narayanan[_2_] Excel Worksheet Functions 2 November 1st 08 11:48 AM
Print area giving me 1 page per cell Coop Excel Discussion (Misc queries) 4 September 19th 07 05:36 AM
Excel spawning a new window when opening a file Rob Excel Worksheet Functions 0 November 7th 06 08:14 PM
Giving FOCUS to Print Preview JimP Excel Programming 0 April 23rd 06 06:54 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"