本文介绍了运行宏而不打开excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何将Excel VBA中编写的VBA代码分配给一个程序/程序,或者可能是dos相关的文件路径,您可以直接在Excel中打开excel。换句话说,我想有一个桌面图标,我可以搅动我分配给的vba代码。解决方案
您可以轻松实现。
添加以下内容在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文件上双击执行它。
资料来源:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!