运行宏而不打开excel [英] Running Macros without opening excel
问题描述
您可以轻松实现。
添加以下内容在VBS文件(例如example.vbs)中。这只是一个可以使用记事本写的文本文件:
'代码应放在.vbs文件中
设置objExcel = CreateObject(Excel.Application)
objExcel.Application.Run'C:\path\to\my\excel\file\myExcelMacroFile.xlsm'!MyModule.MyFunctionName
objExcel.DisplayAlerts = False
objExcel.Application.Quit
设置objExcel =没有
然后你可以在VBS文件上双击执行它。
资料来源: http://wellsr.com/vba/2015/excel/run-macro-without-opening-excel- using-vbscript /
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.
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/
这篇关于运行宏而不打开excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!