0

I have opened a workbook with RDCOMClient and would like to remove the auto filter on a certain sheet:

xlApp <- COMCreate("Excel.Application")
xlApp[['Visible']] <- TRUE 
xlWbk <- xlApp$Workbooks()$Open('file.xlsx')

## sheet with data filters
sheet <- xlWbk$Worksheets('Sheet1')

I've tried a couple things like:

sheet$AutoFilter()[['Value']] = FALSE

and

sheet$AutoFilter()$Filter = FALSE

But haven't been able to quite turn disable the data filter

Rafael
  • 3,096
  • 1
  • 23
  • 61

1 Answers1

1

This does the trick. Looked up the VBA Code and converted it. Should be useful in the future.

sheet[["AutofilterMode"]] <- F
tester
  • 1,662
  • 1
  • 10
  • 16
  • 1
    can you explain 'Looked up the VBA Code and converted it'? – Rafael Nov 10 '20 at 15:34
  • 1
    Yes, I checked how to do it in VBA and then tried to use the syntax in R. See here: https://www.automateexcel.com/vba/turn-autofilter-on-off/ – tester Nov 10 '20 at 19:30