Ric*_*ton 13
编写一个调用VBA的VBscript包装器.请参阅从命令行或批处理文件运行Excel宏的方法?
leb*_*noz 11
这是一个不需要VBscript包装器的方法.您需要安装该RDCOMClient软件包
library(RDCOMClient)
# Open a specific workbook in Excel:
xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open("C:\\Temp\\macro_template.xlsm")
# this line of code might be necessary if you want to see your spreadsheet:
xlApp[['Visible']] <- TRUE
# Run the macro called "MyMacro":
xlApp$Run("MyMacro")
# Close the workbook and quit the app:
xlWbk$Close(FALSE)
xlApp$Quit()
# Release resources:
rm(xlWbk, xlApp)
gc()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22570 次 |
| 最近记录: |