I have a piece of R code in my shiny application that basically triggers a shell script that runs a macro in a excel:
path_to_vbs_file = "www/Macro_Trigger.vbs"
shell(shQuote(normalizePath(path_to_vbs_file)), "cscript", flag = "//nologo")
The .vbs code is:
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
The code works fine on local Windows OS but fails on shinyapps.io server. I tried using system command instead of shell:
path_to_vbs_file = "www/Macro_Trigger.vbs"
system(shQuote(normalizePath(path_to_vbs_file)), intern = FALSE)
But that doesn't help :(
shinyapps.io runs Linux, so executing a VBS script is not going work, unfortunately. My suggestion would be to port your Excel macros to pure R code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.