Excel automation protect sheet and allow filtering

Hi at all,

I would like to allow filtering on protect excel sheet .

This my code :

excel.activesheet.protect("PWD") ' this code works perfectly excel.activesheet.protect.AllowFiltering=true ' don't work

Vba Excel code is :

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True

How to translate it to Xojo ?

Thanks for you help !

Jrme

Hi Jerome,

Maybe try this code in Xojo:

excel.ActiveSheet.Protect("PWD", False, False, False, False, False, False, False, False, False, False, False, False, False, True, False)

Where: excel.ActiveSheet.Protect(Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColums, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables)

The one argument for True is to AllowFiltering and should work in Excel 2013 and later.

This code in VBA:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True

should translate to this in Xojo:

excel.ActiveSheet.Protect("PWD", True, True, True, False, False, False, False, False, False, False, False, False, False, True, False)

Big thanks Eugene :slight_smile: