Hello All,
I have the following code below applied to the workbook, along with more that is not visible but is irrelevant to this question. Two questions to answer. First, is there a way with the following redacted view I have excel to instead of sizing the window by pixes I would like to size the window by a range of cell. Second, when the workbook is deactivated is there a way to have excel remember the last window size to apply to any new workbook that is opened. I would like any new workbook opened to have the last window size and not the current one from this workbook. IDK if either is possible but the latter is more important to me.
I have the following code below applied to the workbook, along with more that is not visible but is irrelevant to this question. Two questions to answer. First, is there a way with the following redacted view I have excel to instead of sizing the window by pixes I would like to size the window by a range of cell. Second, when the workbook is deactivated is there a way to have excel remember the last window size to apply to any new workbook that is opened. I would like any new workbook opened to have the last window size and not the current one from this workbook. IDK if either is possible but the latter is more important to me.
VBA Code:
Private Sub Workbook_Open()
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayHeadings = False
Application.DisplayStatusBar = False
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",False)"
With Application
.WindowState = xlNormal
.Width = 300
.Height = 300
End With
End Sub
Private Sub Workbook_Activate()
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayHeadings = False
Application.DisplayStatusBar = False
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",False)"
End Sub
Private Sub Workbook_Deactivate()
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayHeadings = True
Application.DisplayStatusBar = True
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayHeadings = True
Application.DisplayStatusBar = True
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
End Sub