Hi everyone, I hope you're well.
I've created a workbook that when opened, you're greeted with a dashboard of spliced pivot charts.
I've made it so when opened, it removes the following:
Scroll bars.
Formula Bar.
Headings.
Toolbar.
Ability to scroll.
The issue I've got is, I don't want it to affect a new instance of Excel, or if someone opens another workbook.
My code is as follows:
I've tried to tackle this with the If ThisWorkbook.Name = - along with if it's the active workbook
Is what I'm trying to do even possible?
Any help would be greatly appreciated.
Thank you.
Regards
Marhier.
I've created a workbook that when opened, you're greeted with a dashboard of spliced pivot charts.
I've made it so when opened, it removes the following:
Scroll bars.
Formula Bar.
Headings.
Toolbar.
Ability to scroll.
The issue I've got is, I don't want it to affect a new instance of Excel, or if someone opens another workbook.
My code is as follows:
Code:
Private Sub Workbook_Open()
If ThisWorkbook.Name = "Purchasing Spend Source Data.xlsm" And ActiveWorkbook Is ThisWorkbook Then
Dim ws As Worksheet
Dim Sheet As Worksheet, Pivot As PivotTable
Dashboard.Select
For Each ws In ThisWorkbook.Sheets
If ws.Name = "Dashboard" Then
ws.Unprotect
DisplayHorizontalScrollBar = False
DisplayVerticalScrollBar = False
Application.DisplayFormulaBar = False
ActiveWindow.DisplayHeadings = False
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",False)"
Sheets("Dashboard").ScrollArea = "A1"
ws.Protect
End If
Next ws
For Each Sheet In ThisWorkbook.Worksheets
For Each Pivot In Sheet.PivotTables
Pivot.RefreshTable
Pivot.Update
Next
Next
End If
End Sub
I've tried to tackle this with the If ThisWorkbook.Name = - along with if it's the active workbook
Is what I'm trying to do even possible?
Any help would be greatly appreciated.
Thank you.
Regards
Marhier.