1

I'm trying to call a macro from R, and I have followed the answer to this question but I het an error:

<checkErrorInfo> 80020009 
Error: Exception occurred.

My code is the following:

library(RDCOMClient)

# Open a specific workbook in Excel:
xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open("Y:\\macroR.xlsm")

# this line of code might be necessary if you want to see your spreadsheet:
xlApp[['Visible']] <- FALSE 

# Run the macro called "MyMacro":
xlApp$Run("LoopAllExcelFilesInFolder")

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

# Release resources:
rm(xlWbk, xlApp)

The macro is supposed to remove all the strikethrough cells in all the worksheets in all workbooks contained in a folder selected by the user. I can share the code if it is relevant.

YowE3K
  • 23,852
  • 7
  • 26
  • 40
Barbara
  • 1,118
  • 2
  • 11
  • 34

0 Answers0