Hi,
I am trying to call VBA excel macros in R studio ,But unfortunatly am getting below error when trying to run the macro.As i need to schedule excel kind of report by calling VBA macros which exist in excel as part of report .
So kindly help me the right approach if this is not the correct way..
Sample code which am using :
install.packages("RDCOMClient", repos = "http://www.omegahat.net/R")
library(RDCOMClient)
library(openxlsx)
# Open a specific workbook in Excel:
xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open("D:/Documents/vba22/Book2.xlsm")
# this line of code might be necessary if you want to see your spreadsheet:
xlApp[['Visible']] <- TRUE
# Run the macro called "MyMacro":
Sys.sleep(1)
xlApp$Run("Cyan")
# Close the workbook and quit the app:
xlWbk$Close(FALSE)
xlApp$Quit()
# Release resources:
rm(xlWbk, xlApp)
gc()
Error :slight_smile:
<checkErrorInfo> 80020009
Error: Exception occurred.