Batch file to read from xlsx file RRS feed

  • Question

  • Hi Guys,

    I would like to create a small batch file that reads cells in a excel sheet and then select a default printer based on the contents of cells.

    Excel Sheet-->

    Week | SCT1 | SCT2 | SCT3

    9 | XXX | YYY| ZZZ
    10 | RRR| CCC | XXX
    11 | YYY | RRR| ZZZ

    *SCTs are names
    *Week of the year

    What the batch file should do is check if user's name is in a SCT in the current week. If yes {do something} if not, then {do something}

    Somethign like this:

    1. Batch file to ask for the user's name and store it into a variable: SET /P username=Please enter your name:
    2. Check what is today's week number
    3. Look into the "week" column and check if username is in the SCT1, SCT2 or SCT3 fields
    4. Depending on the result set printer: RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n [printer name] 

    I checked around and in powershell it seems to be easier, but unfortunately I don't know powershell.

    I would appreciate if the code could be shared with me so that I copy-paste into a .bat file and works :)

    Thank you

    Monday, February 24, 2014 11:31 AM


  • Batch files cannot digest Excel files. You need to use PowerShell (as you have already found out) or VBScript. In either case it is unlikely that a respondent will deliver a solution on a platter. You must do your own research, e.g. in the Script Repository, and teach yourself the basics of the chosen language. When you have a script and understand how it works, post it here to get assistance with the finer points.
    Monday, February 24, 2014 11:56 AM