J'ai une remarque sur cette ligne
.insertLines LineNum, Chr(9) & "For each sh in wb"
Il fallait
.insertLines LineNum, Chr(9) & "For each sh in thisworkbook.worksheets"
mieux ainsi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Public Sub AddEnableOutliningCode(ByRef vWb As Workbook, ByVal vModuleName As String)
Dim code As String
Dim LineNum As Long
code = "Private Sub Workbook_Open()"
code = code & vbCrLf & "Dim sh as Worksheet"
code = code & vbCrLf & "For each sh in thisworkbook.worksheets"
code = code & vbCrLf & "sh.EnableOutlining = True"
code = code & vbCrLf & "sh.Protect Contents:= True, UserInterfaceOnly:= True"
code = code & vbCrLf & "next sh"
code = code & vbCrLf & "end sub"
With vWb.VBProject.VBComponents.Item(vModuleName).CodeModule
LineNum = .CountOfLines + 2
.insertLines LineNum, code
End With
End Sub |
Partager