|
|
|
|
|
|
Excel
|
Set your workbook to adjust to users screen resolution.
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2000, 2003
|
Submitted by:
|
johnske
|
Description:
|
On opening, the users screen resolution is checked, then the workbooks properties are adjusted so that it's always viewed in the same proportion on all PCs. In the attached example, the workbook is positioned in the top LH corner of the monitor and its height and width are set at approximately 2/3 of the user's monitor's height and width.
|
Discussion:
|
When the workbook contains graphics, these may not appear as they should when viewed at a different screen resolution. In such cases all the required settings can be made by the person providing the workbook so that the graphics should appear in the same proportion to all viewers whatever their screen resolution may be. (Even when not used on another machine, this is handy when you want the book to always open at the same size and position on your monitor).
|
Code:
|
instructions for use
|
Option Explicit
Private Sub Workbook_Open()
Run ("MonitorInfo")
With Application
.WindowState = xlNormal
.Top = 1
.Left = 1
.Width = 400 * ScrWidth / 800
.Height = 300 * ScrHeight / 600
With .ActiveWindow
.WindowState = xlNormal
.Top = 1
.Left = 1
.Zoom = 100 * ScrWidth / 800
.Width = Application.UsableWidth
.Height = Application.UsableHeight
End With
End With
End Sub
Option Explicit
Public ScrWidth&, ScrHeight&
Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex&) As Long
Private Sub MonitorInfo()
ScrWidth = GetSystemMetrics32(0)
ScrHeight = GetSystemMetrics32(1)
End Sub
|
How to use:
|
- Open an Excel workbook
- Select Tools/Macro/Visual Basic Editor
- In the VBE window, select Insert/Module
- Copy and paste the "code for the standard module" into this Module
- Select View/Project Explorer
- Select the ThisWorkbook module
- Copy and paste the "code for the ThisWorkbook module" to this Module
- Now select File/Close and Return To Microsoft Excel
- Don't forget to save your changes...
|
Test the code:
|
- By dragging...
- Manually re-size and reposition your application window (the outer frame)
- Manually re-size and reposition your "workbook"window (the inner frame)
- Save and close the book
- On re-opening, the book will re-size and re-position itself according to your coded settings
- (The example "resolution.xls" will be around 2/3 the height & width of your monitor)
|
Sample File:
|
resolution.zip 9.58KB
|
Approved by mdmackillop
|
This entry has been viewed 457 times.
|
|