[转]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.

猜你喜欢

转载自www.cnblogs.com/freeliver54/p/11271594.html