GRCArizona
Board Regular
- Joined
- Apr 24, 2010
- Messages
- 95
Hi -
I'm trying to understand the 'UserInterface' feature in VBA. I have a file with several charts and macros. On one worksheet, if a macro is selected, it will add a Trendline on a chart. Since the worksheet is protected, the macro is erroring out at:
ActiveSheet.ChartObjects("Chart 1").Activate
Here is my code I'm using on the 'Worksheet_Open' event:
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
wks.EnableOutlining = True
wks.Protect Password:="aaa", DrawingObjects:=False, Contents:=True, Scenarios:= _
False, UserInterfaceonly:=True, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
Next wks
Is there anything else needed to allow for charts to be accessed?
thanks,
GRC
I'm trying to understand the 'UserInterface' feature in VBA. I have a file with several charts and macros. On one worksheet, if a macro is selected, it will add a Trendline on a chart. Since the worksheet is protected, the macro is erroring out at:
ActiveSheet.ChartObjects("Chart 1").Activate
Here is my code I'm using on the 'Worksheet_Open' event:
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
wks.EnableOutlining = True
wks.Protect Password:="aaa", DrawingObjects:=False, Contents:=True, Scenarios:= _
False, UserInterfaceonly:=True, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
Next wks
Is there anything else needed to allow for charts to be accessed?
thanks,
GRC