问题描述
我想运行存储在个人文件中的宏而不打开我的实际excel文件.
I would like to run macro stored in personal file without opening my actual excel file.
我如何修改以下代码以实现此目的
How do i modify the following code to achieve this
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'D:\Sample SSRS\power View\AlertHistory.xlsm'!Module1.getDataImported"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
我的另一个问题是我尝试记录一个宏,该宏打开excel mysql选项并追加数据,但未记录该功能.我想将工作表1中的所有数据附加到我的mysql表中
My other question is I have tried recording a macro that opens the excel mysql option and appends data but that functionality is not being recorded. I would like to append all data from sheet 1 to my mysql table
推荐答案
我当时正为同样的问题而苦苦挣扎,最终我弯腰寻找解决方案.
I was struggling with the same problem and I eventually meandered my way to a solution.
基本上,我:
-
以编程方式打开了我需要运行个人宏"的工作簿,
programmatically opened the workbook in which I needed to run the Personal Macro,
使用Application.Run
调用个人宏文件(PERSONAL.XLSB
)
used Application.Run
to call up the Personal Macro file (PERSONAL.XLSB
),
然后指定了模块,然后指定了要在其中运行的宏.
then specified the module and then macro to run within it.
这似乎可行...不过,我不知道这是否是一种超级优雅的解决方案.
It seems to work ... I don't know if it's a super elegant solution, though.
下面是代码.请注意,Jan2017xlsm
是运行个人宏所需的文件的文件夹位置.
Below is the code. Note that Jan2017xlsm
is the folder location of the file I needed to run the personal macro in.
这篇关于在不打开Excel的情况下运行personal.xlsb宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!