80020009 Error in .COM (x, name, ...):" in R while accessing excel file I automated the process of accessing VBA macr...">

Getting "<checkErrorInfo> 80020009 Error in .COM (x, name, ...):" in R while accessing excel file

I automated the process of accessing VBA macros from R using the Openxlsx and RDCOMclient packages. Below is the code:

Function:

OpenExcel_5param <- function(directory,filename, MacroName, param1, param2, 
param3,param4, param5)
{

 # Open a specific workbook in Excel:
   data <- paste(c(directory,'/',filename,'.xlsm'), collapse = '')
   xlApp <- COMCreate("Excel.Application")
   xlWbk <- xlApp$Workbooks()$Open(data)

 # this line of code might be necessary if you want to see your spreadsheet:
   xlApp[['Visible']] <- TRUE 
   xlApp$Run(MacroName,param1,param2, param3, param4, param5)

 # Close the workbook and quit the app:
   xlWbk$Close(FALSE)
   xlApp$Quit()

 # Release resources:
   rm(xlWbk, xlApp)
   gc()
}

Code to access this function:

OpenExcel_5param (Common_folder, VBA_CodeFileName, "ConsumptionValidation.MARM", r_extracts, "1. UniqueUPC_Nielsen", 10000, original_files, "MARM")

When I run the code, I get the following error:

80020009
Error in .COM (x, name, ...):

, . , . . , excel , . R, .

+4

Source: https://habr.com/ru/post/1693025/


All Articles