[转]Introduction - Run Excel Macro using VBScript

本文转自:https://wellsr.com/vba/2015/excel/run-macro-without-opening-excel-using-vbscript/

Have you ever wanted to run an Excel Macro without actually opening Excel? Follow this tutorial to learn how you can make that happen with VBScript.

 

Example

Run Macro from Outside Excel

'Code should be placed in a .vbs file
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\Users\Ryan\Desktop\Sales.xlsm'!SalesModule.SalesTotal"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing

Write better macros in half the time
I see people struggling with Excel every day and I want to help. That's why I'm giving away my personal macro library for free. This powerful gift lets you automatically import all my macros directly into your spreadsheet with just one click.

上一篇:javascript – VBScript chr()似乎返回错误的值


下一篇:javascript – 在添加新行时将焦点设置到div内部的表格末尾