+ Reply to Thread
Results 1 to 6 of 6

What is the command-line print switch in Excel?

  1. #1
    eeidfn
    Guest

    What is the command-line print switch in Excel?

    Opening Excel 2003 from the command-line as follows works:
    "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e C:\excelFile.xls

    But how do I print from the command-line?

    Thanks.

  2. #2
    Kevin B
    Guest

    RE: What is the command-line print switch in Excel?

    The only command line switches that I know of are /r for read-onoyo, /e to
    prevent the display of the startup screen and a blank workbook, and /p to
    specify the working folder path.

    I don't believe you initiate and Excel print job from the command line.
    --
    Kevin Backmann


    "eeidfn" wrote:

    > Opening Excel 2003 from the command-line as follows works:
    > "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e C:\excelFile.xls
    >
    > But how do I print from the command-line?
    >
    > Thanks.


  3. #3
    Steve Yandl
    Guest

    Re: What is the command-line print switch in Excel?

    I don't think you can do it directly from a command line. You could use a
    somewhat indirect approach with a vbScript. If you save what I've got
    between the lines below as a text file with a VBS extension (for example,
    C:\Test\PrintWkbk.vbs) then you can either drag xls files into the vbs or a
    shortcut to it or you can use a command line like:
    C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    to print the Workbook. Note that if you have disabled file associations for
    scripts, you may have to use the command line
    WScript.exe C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"

    _____________________________________________________________

    Const xlDoNotSaveChanges = 2

    Dim fso, oXL, oWkbk

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oXL = CreateObject("Excel.Application")

    oXL.Visible = False

    If WScript.Arguments.Count = 0 Then
    WScript.Quit
    Else
    For A = 0 To (WScript.Arguments.Count - 1)
    If (Right(WScript.Arguments.Item(A), 3) = "xls") _
    AND fso.FileExists(WScript.Arguments.Item(A)) Then
    Set oWkbk = oXL.Workbooks.Open(WScript.Arguments.Item(A))
    oWkbk.PrintOut
    oWkbk.Close xlDoNotSaveChanges
    End If
    Next
    End If

    oXL.Quit
    Set fso = Nothing
    Set oXL = Nothing
    _____________________________________________________________

    Steve Yandl




    "eeidfn" <[email protected]> wrote in message
    news:[email protected]...
    > Opening Excel 2003 from the command-line as follows works:
    > "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e C:\excelFile.xls
    >
    > But how do I print from the command-line?
    >
    > Thanks.




  4. #4
    eeidfn
    Guest

    Re: What is the command-line print switch in Excel?

    Steve,
    That worked great. It also works if the file happens to be open already.

    The only drawback is that VBS support is required in addition to Excel being
    installed. Is WScript and Visual Basic Script standard on Windows 2000 and
    XP?

    Thanks.

    "Steve Yandl" wrote:

    > I don't think you can do it directly from a command line. You could use a
    > somewhat indirect approach with a vbScript. If you save what I've got
    > between the lines below as a text file with a VBS extension (for example,
    > C:\Test\PrintWkbk.vbs) then you can either drag xls files into the vbs or a
    > shortcut to it or you can use a command line like:
    > C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    > to print the Workbook. Note that if you have disabled file associations for
    > scripts, you may have to use the command line
    > WScript.exe C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    >
    > _____________________________________________________________
    >
    > Const xlDoNotSaveChanges = 2
    >
    > Dim fso, oXL, oWkbk
    >
    > Set fso = CreateObject("Scripting.FileSystemObject")
    > Set oXL = CreateObject("Excel.Application")
    >
    > oXL.Visible = False
    >
    > If WScript.Arguments.Count = 0 Then
    > WScript.Quit
    > Else
    > For A = 0 To (WScript.Arguments.Count - 1)
    > If (Right(WScript.Arguments.Item(A), 3) = "xls") _
    > AND fso.FileExists(WScript.Arguments.Item(A)) Then
    > Set oWkbk = oXL.Workbooks.Open(WScript.Arguments.Item(A))
    > oWkbk.PrintOut
    > oWkbk.Close xlDoNotSaveChanges
    > End If
    > Next
    > End If
    >
    > oXL.Quit
    > Set fso = Nothing
    > Set oXL = Nothing
    > _____________________________________________________________
    >
    > Steve Yandl
    >
    >
    >
    >
    > "eeidfn" <[email protected]> wrote in message
    > news:[email protected]...
    > > Opening Excel 2003 from the command-line as follows works:
    > > "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e C:\excelFile.xls
    > >
    > > But how do I print from the command-line?
    > >
    > > Thanks.

    >
    >
    >


  5. #5
    Steve Yandl
    Guest

    Re: What is the command-line print switch in Excel?

    Yes, vbs support and the Script Host are included. It can be downloaded for
    free from Microsoft if you have any Win98 systems but it's standard on WinXP
    and Win2k.

    I like to place shortcuts to this sort of script in my SendTo folder rather
    than type out command lines with arguments but do what suits your needs
    best.

    Steve


    "eeidfn" <[email protected]> wrote in message
    news:[email protected]...
    > Steve,
    > That worked great. It also works if the file happens to be open already.
    >
    > The only drawback is that VBS support is required in addition to Excel
    > being
    > installed. Is WScript and Visual Basic Script standard on Windows 2000
    > and
    > XP?
    >
    > Thanks.
    >
    > "Steve Yandl" wrote:
    >
    >> I don't think you can do it directly from a command line. You could use
    >> a
    >> somewhat indirect approach with a vbScript. If you save what I've got
    >> between the lines below as a text file with a VBS extension (for example,
    >> C:\Test\PrintWkbk.vbs) then you can either drag xls files into the vbs or
    >> a
    >> shortcut to it or you can use a command line like:
    >> C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    >> to print the Workbook. Note that if you have disabled file associations
    >> for
    >> scripts, you may have to use the command line
    >> WScript.exe C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    >>
    >> _____________________________________________________________
    >>
    >> Const xlDoNotSaveChanges = 2
    >>
    >> Dim fso, oXL, oWkbk
    >>
    >> Set fso = CreateObject("Scripting.FileSystemObject")
    >> Set oXL = CreateObject("Excel.Application")
    >>
    >> oXL.Visible = False
    >>
    >> If WScript.Arguments.Count = 0 Then
    >> WScript.Quit
    >> Else
    >> For A = 0 To (WScript.Arguments.Count - 1)
    >> If (Right(WScript.Arguments.Item(A), 3) = "xls") _
    >> AND fso.FileExists(WScript.Arguments.Item(A)) Then
    >> Set oWkbk = oXL.Workbooks.Open(WScript.Arguments.Item(A))
    >> oWkbk.PrintOut
    >> oWkbk.Close xlDoNotSaveChanges
    >> End If
    >> Next
    >> End If
    >>
    >> oXL.Quit
    >> Set fso = Nothing
    >> Set oXL = Nothing
    >> _____________________________________________________________
    >>
    >> Steve Yandl
    >>
    >>
    >>
    >>
    >> "eeidfn" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > Opening Excel 2003 from the command-line as follows works:
    >> > "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e
    >> > C:\excelFile.xls
    >> >
    >> > But how do I print from the command-line?
    >> >
    >> > Thanks.

    >>
    >>
    >>




  6. #6
    Steve Yandl
    Guest

    Re: What is the command-line print switch in Excel?

    Actually, even if you have Win98 systems, the scripting runtimes are
    standard. Some great new tools that involve WMI (which were not used for
    the above script) require more than is found in Win98 but that isn't an
    issue here. Your only concern will be systems where script support has been
    turned off for security.

    Steve


    "Steve Yandl" <[email protected]> wrote in message
    news:[email protected]...
    > Yes, vbs support and the Script Host are included. It can be downloaded
    > for free from Microsoft if you have any Win98 systems but it's standard on
    > WinXP and Win2k.
    >
    > I like to place shortcuts to this sort of script in my SendTo folder
    > rather than type out command lines with arguments but do what suits your
    > needs best.
    >
    > Steve
    >
    >
    > "eeidfn" <[email protected]> wrote in message
    > news:[email protected]...
    >> Steve,
    >> That worked great. It also works if the file happens to be open already.
    >>
    >> The only drawback is that VBS support is required in addition to Excel
    >> being
    >> installed. Is WScript and Visual Basic Script standard on Windows 2000
    >> and
    >> XP?
    >>
    >> Thanks.
    >>
    >> "Steve Yandl" wrote:
    >>
    >>> I don't think you can do it directly from a command line. You could use
    >>> a
    >>> somewhat indirect approach with a vbScript. If you save what I've got
    >>> between the lines below as a text file with a VBS extension (for
    >>> example,
    >>> C:\Test\PrintWkbk.vbs) then you can either drag xls files into the vbs
    >>> or a
    >>> shortcut to it or you can use a command line like:
    >>> C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    >>> to print the Workbook. Note that if you have disabled file associations
    >>> for
    >>> scripts, you may have to use the command line
    >>> WScript.exe C:\Test\PrintWkbk.vbs "C:\xlFiles\Text.xls"
    >>>
    >>> _____________________________________________________________
    >>>
    >>> Const xlDoNotSaveChanges = 2
    >>>
    >>> Dim fso, oXL, oWkbk
    >>>
    >>> Set fso = CreateObject("Scripting.FileSystemObject")
    >>> Set oXL = CreateObject("Excel.Application")
    >>>
    >>> oXL.Visible = False
    >>>
    >>> If WScript.Arguments.Count = 0 Then
    >>> WScript.Quit
    >>> Else
    >>> For A = 0 To (WScript.Arguments.Count - 1)
    >>> If (Right(WScript.Arguments.Item(A), 3) = "xls") _
    >>> AND fso.FileExists(WScript.Arguments.Item(A)) Then
    >>> Set oWkbk = oXL.Workbooks.Open(WScript.Arguments.Item(A))
    >>> oWkbk.PrintOut
    >>> oWkbk.Close xlDoNotSaveChanges
    >>> End If
    >>> Next
    >>> End If
    >>>
    >>> oXL.Quit
    >>> Set fso = Nothing
    >>> Set oXL = Nothing
    >>> _____________________________________________________________
    >>>
    >>> Steve Yandl
    >>>
    >>>
    >>>
    >>>
    >>> "eeidfn" <[email protected]> wrote in message
    >>> news:[email protected]...
    >>> > Opening Excel 2003 from the command-line as follows works:
    >>> > "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e
    >>> > C:\excelFile.xls
    >>> >
    >>> > But how do I print from the command-line?
    >>> >
    >>> > Thanks.
    >>>
    >>>
    >>>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1