Thank you for Visiting my Blog

Sunday, 26 March 2017

Run Excel Macro using VBScript Script File



Save below content in a notepad with ".VBS" extension .Once it successfully save click on the file icon to run it .














 Set objExcel = CreateObject("Excel.Application")
' excel complete path including macro name  --------------'

objExcel.Application.Run "'C:\Users\Jaya\Desktop\Run_Macro.xlsm'!runmacromodule.runmacro"

objExcel.DisplayAlerts = False
objExcel.Application.Save
objExcel.Application.Quit
Set objExcel = Nothing


Customization:

1. The objExcel.Application.Run would check for Excel sheet path, Module name and macro name which need to run...
 
objExcel.Application.Run "'Path\WorkbookName.xlsm'!Module.Macro_Name"


2. objExcel.Application.Save , will ensure that work book should be saved after successfully execution  and before quitting the program objExcel.Application.Quit.













 

1 comment:

  1. Very much Helpful blog and content. Thank you.

    ReplyDelete