title: Excel: EnableOutlining seems to default to False on opening workbook
body: <p>Like many other people, I want to be able to enable grouping and ungrouping with the little +/- buttons on a protected worksheet. Everyone seems to have succeeded with the same sort of code that protects the worksheet, enables outlining and then unprotects it again, which is great and it works except if I save the sheet and then re-open it again EnableOutlining is always set as False, and if the sheet is protected I cannot use the +/- buttons. Is there something else I am supposed to do to save this setting permanently, and not just for the duration of the session?</p>
  
  <p>Here's the code I have been using:</p>
  
  <pre><code>Private Sub Workbook_Open()
  MsgBox ActiveSheet.EnableOutlining
  End Sub
  
  Sub EnableOutliningWithProtection_AllSheets()
  'PURPOSE: Allow Outline functionality during Protection in all Sheets
  'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
  '(Except edited by me to include the Errorcatch)
  
  Dim sht As Worksheet
  On Error GoTo Errorcatch
  'Loop through each Worksheet in ActiveWorkbook
    For Each sht In ActiveWorkbook.Worksheets
      'Password Protect Current Sheet
        sht.Protect Password:="", UserInterfaceOnly:=True
  
      'Enable Group Collapse/Expand Capabilities
        sht.EnableOutlining = True
  
      'Unprotect Sheet
        sht.Unprotect ""
  
    Next sht
  
  Exit Sub
  Errorcatch:
  MsgBox Err.Description
  
  End Sub
  </code></pre>
  
  <p>(I've got the Workbook_Open() bit to check if EnableOutlining was still True)
  I've seen the 'protect UserInterfaceOnly and EnableOutlining' question, but I didn't think the results applied as the code was written for C#, and I'm not looking at protecting UserInterfaceOnly.</p>