• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

using vbscript to run excel macro from batch file

ccarruth

Member
Have excel workbook with functioning macro that works perfectly. Want to use vb script to execute macro without having to open the workbook, then use bat file to launch script using Win Scheduler. Very simple but worn't run, meaning batch file starts but nothing happens after, just a flash on the screen. Hope this is the right forum, if not my apologies.

VB script file (SDMacroScript.vbs) language:

Code:
Dim args, objExcel

Set args = wScript.Arguments
Set objExcel = CreateObject("Excel.Application")

objExcel.workbooks.Open args(0)
objExcel.visible = False

objExcel.Run "StrmDig_Macro_ReOcrnc.xlsm!StrmDigPrcs.StrmDigPrcs"

objExcel.Activeworkbook.Close(0)
objExcel.Quit

bach file:
----------------
cscript SDMacroScript.vbs "E:\Main BE\StrmDig_Macro_ReOcrnc.xlms"
help!
 
Last edited by a moderator:
Your batch script has typo (see bold part)
cscript SDMacroScript.vbs "E:\Main BE\StrmDig_Macro_ReOcrnc.xlms"

When testing batch script I normally use "pause" at the end so that the DOS screen remains and doesn't close.
 
Back
Top