Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code below that modifies a workbook to eliminate tabs, ribbons, formula bars, scrollbars and what not). It resides in wb1 but is applied to wb2 (so it's not the calling workbook that get modified, it's wb2). Everything seems to be working well, but I am unable to centre the resized window on my monitor with the code I found and applied.
The window size is static at 480px x 250px, but the top and left values are variable I hope based on the size of the monitor. I don't want to make the changes at the application level because I wish to keep wb1 maximized behind wb2 (in its resized and centred state.)
I am receiving an error : "Unable to set the width property of the Window class". with the line in red.
Rich (BB code):
Sub ReadingView()
Dim maxWidth As Integer
Dim maxHeight As Integer
Dim appLeft As Integer
Dim appTop As Integer
With Application
With Workbooks("permit_info.xlsm")
Application.windowstate = xlMaximized
maxWidth = Application.Width
maxHeight = Application.Height
' store current ActiveWorkbook settings
View.drawingobjects = .DisplayDrawingObjects
' set
Windows("permit_info.xlsm").Visible = True
Workbooks("permit_info.xlsm").Worksheets("FORM").Activate
End With
With ActiveWindow
' store current ActiveWindow settings
View.headings = .DisplayHeadings
View.gridlines = .DisplayGridlines
View.hscrollbar = .DisplayHorizontalScrollBar
View.vscrollbar = .DisplayVerticalScrollBar
View.wkbtabs = .DisplayWorkbookTabs
' set
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
.DisplayGridlines = False
appLeft = maxWidth / 2
appTop = maxHeight / 2
.Width = 480
.Height = 250
.Top = appTop
.Left = appLeft
End With
' set
.ExecuteExcel4Macro _
"SHOW.TOOLBAR(""Ribbon"",False)"
' store current Application Settings
View.formulabar = .DisplayFormulaBar
View.statusbar = .DisplayStatusBar
'set
.DisplayFormulaBar = False
.DisplayStatusBar = False
End With
End Sub
The window size is static at 480px x 250px, but the top and left values are variable I hope based on the size of the monitor. I don't want to make the changes at the application level because I wish to keep wb1 maximized behind wb2 (in its resized and centred state.)
I am receiving an error : "Unable to set the width property of the Window class". with the line in red.