Student Mode Code Display

Welcome to the Fraternity!

Commenting has been enabled. You can comment on all the Code Items now.

Run Macro Code from VBS file Excel Operation

Add This Code to My Favourite List
Enter Email

Contributed By admin
Date 2016-05-26 07:08:40

'This VBs file is to Demonstrate how to Run Macro from VBS File
'Author: Akash Tyagi

Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("F:\AkashDocs\runmacrobyvbs\newMacroFile.xlsm")

'This could be Used Somtimes, tough Not required.
'objExcel.AddIns("InsideModule").Installed = True

'If Function is Located at
'Module:xlApp.Application.Run "!"
'Sheet:xlApp.Application.Run "!."
'Function with Argument: 
'xlApp.Application.Run "!.(,..)"

'If Function in located in Module
objExcel.Application.Run "NewMacroFile.xlsm!InsideModule"

'If Function is located in Sheet for example "Sheet1"
objExcel.Application.Run "NewMacroFile.xlsm!Sheet1.InsideSheet"

'If Function is in located in Module and have arguments to pass
'Same for function present in Sheets
'Remember to escape double quotes for the Arguments
objExcel.Application.Run "NewMacroFile.xlsm!InsideModuleWithArgument(""123"",""454"")"


Download Above Code


Add your comments...
Name : *      
Email : *      
The content of this field will be kept private and will not be shown publicly

Your Comment/Answer *

Enter the text present in this box : *