我的闪亮应用程序中有一段R代码,它基本上触发了一个在excel中运行宏的shell脚本:
path_to_vbs_file = "www/Macro_Trigger.vbs"
shell(shQuote(normalizePath(path_to_vbs_file)), "cscript", flag = "//nologo")
.vbs代码是:
Option Explicit
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Dim fso
Dim curDir
Set xlApp = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetParentFolderName(wscript.ScriptFullName)
Set xlBook = xlApp.Workbooks.Open(curDir & "\KPI_Report.xlsm", 0, False)
xlApp.Application.Visible = False
xlApp.DisplayAlerts = False
xlApp.Run "ConvertTextToNumber"
xlApp.ActiveWorkbook.SaveAs curDir & "\KPI_Report.xlsm"
xlApp.ActiveWorkbook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
该代码在本地Windows操作系统上运行正常,但在shinyapps.io服务器上失败。我尝试使用系统命令而不是shell:
path_to_vbs_file = "www/Macro_Trigger.vbs"
system(shQuote(normalizePath(path_to_vbs_file)), intern = FALSE)
但这并没有帮助:(
答案 0 :(得分:0)
shinyapps.io运行Linux,不幸的是,执行VBS脚本不起作用。我的建议是将Excel宏移植到纯R代码。