Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Macros without opening excel

I wonder how would you assign VBA codes written on Excel VBA to a sort of procedure/programme or maybe dos related filepath, which you can directly without opening excel. In other word, i want to have a desktop icon i can stir up a vba code i assigned to.

like image 288
serhat Avatar asked Oct 26 '25 02:10

serhat


1 Answers

You can do it easily.

Add the following content in a VBS file (e.g. example.vbs). This is only a text file that you can write using Notepad:

'Code should be placed in a .vbs file
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\path\to\my\excel\file\myExcelMacroFile.xlsm'!MyModule.MyFunctionName"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing

Then you can double clic on the VBS file to execute it.

Source: http://wellsr.com/vba/2015/excel/run-macro-without-opening-excel-using-vbscript/

like image 162
Julien Kronegg Avatar answered Oct 27 '25 18:10

Julien Kronegg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!