Print excel file from DOS command line

D

despistado

It's possible to pass a parameter to VB ? (I never use VB)
I need it becase I need to print different workbook with a .bat
 
D

Dave Peterson

I create a PrintXLS.VBS file and put it in a safe spot.
(I put it in "C:\my documents\scripting\printxls.vbs")

This was in the file:

Dim XL
Dim XLWkbk
Dim ObjArgs

set objargs = wscript.arguments

if objArgs.count <> 1 then
wscript.echo "invalid passed arguments"
wscript.quit
end if

Set XL = CreateObject("excel.application")
XL.Visible = True

Set XLWkbk = XL.Workbooks.Open(objargs(0))

XLWkbk.PrintOut

XLWkbk.Close False
XL.Quit

Set XLWkbk = Nothing
Set XL = Nothing
set ObjArgs = nothing


Then I created a shortcut to this .vbs file and dropped it on the desktop.

I rightclicked on that shortcut and clicked on properties.

In the target box, I put:
"C:\my documents\scripting\printxls.vbs" "c:\my documents\excel\book1.xls"

I applied and then test it out and it worked ok for me.

But you have now reached the end of my VBS knowledge (even with google!). If
you have more questions about scripting, I'd recommend that you post in one of
the several scripting newsgroups.

Explain what you want to do and I bet you'll get help.
 
Top