[AccessD] Screen Resolution

James Button jamesbutton at blueyonder.co.uk
Mon Mar 20 05:00:25 CDT 2023


A further thought re the actual request -
For the apps I wrote using Excel I had to add a window sizing and positioning
macro to run when a new workbook was opened by the macro(s) under the changed
process of 2016.
As in separate Excel window rather than within the single one of 2010.
Adjustable parameters are location of top left corner, width and depth of window
and of the presentation of the data within that  'tab', and zoom of the view.
Maybe that is something that you can do for your Access Application.
Crude version of EXCEL code below! Maybe use a % for the zoom rather than just
"fit"

JimB
-------------------------
Sub windowfix2016()

' For excel 2016 - Change the window size, range & ribbon status .....
' only for office 2016  but if 2013 also needs dealing with that will be test
for version 15
If Application.Version < 16 Then
 nn = ""
 Else
 
' This is to be called by the macros that open of CRT_Model  etc.
' use a Global setting for all window realignments - this can be set according
to the users wishes
' After doing the active .screen .workbook & .worksheet it will then set the
ribbon as requested

    Dim iRibbon As Integer    ' 0 = none, 1 = Menu, 2 = Commands too, 3= Leave
as is
    Dim iStartX As Integer
    Dim iStartY As Integer
    Dim iDesiredWidth As Integer
    Dim iDesiredHeight As Integer
    Dim iviewrange As String
    iRibbon = 1               ' 0 = none, 1 = Menu, 2 = Commands too, 3= Leave
as is
    iStartX = 50              ' Distance from left
    iStartY = 25              ' Distance from top
    iDesiredWidth = 600
    iDesiredHeight = 500
    iviewrange = "A1:G35"     ' Note the columns are what matters
    

    With Application
        .WindowState = xlMaximized
        iMaxWidth = Application.Width           ' max end is the window end in
fullscreen
        iMaxHeight = Application.Height
        iMaxWidth = iMaxWidth - iStartX         ' Adjust window for starting
point
        iMaxHeight = iMaxHeight - iStartY
        If iDesiredWidth > iMaxWidth Then iDesiredWidth = iMaxWidth
        If iDesiredHeight > iMaxHeight Then iDesiredHeight = iMaxHeight
        .WindowState = xlNormal                 ' so now set the window
        .Top = iStartY
        .Left = iStartX
        .Width = iDesiredWidth
        .Height = iDesiredHeight
    End With
' and now fit the selected range into that window
    ActiveSheet.Range(iviewrange).Select
    ActiveWindow.Zoom = True
    
' Now for the ribbon setting
    
    If iRibbon = 3 Then
       iRibbon = 3            ' do nothing
    Else

' In Word:
' ActiveWindow.ToggleRibbon has the same effect as double-clicking on a ribbon
tab.
' In Excel: this swaps the state to lose the menu and ribbon, or reinstate it
'  RibbonHeight <100 (=73?) seems to mean it is hidden, or in no commands mode
'  RibbonHeight >100 (well >73?) seems to mean it is not hidden, and is also
showing commands
' (hidden you get full-screen usage, with tabs showing
'                        Restore sets it to windowed without the menu

        Dim iribbonheight As Long
        Dim iribbonstate As Long
        iribbonstate =
Application.ExecuteExcel4Macro("Get.ToolBar(7,""Ribbon"")")
        iribbonheight = CommandBars("Ribbon").Controls(1).Height
' So - switch ribbon  on/off state
'                       Off = full screen filename at top and tabs at bottom
'                        on  is ribbon with, or without commands - as determined
by the CommanBars.ExecuteMSO MinimizeRibbon
'                     But Show False hides all the surround of the page and
full-window's it.
'                     need to use the setting for "show tabs" rather than
"Autohide" or "Show tabs and Commands"
    
        If iRibbon = 0 Then
            Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"", False)"   '
0 = no ribbon
        Else
            Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"", True)"    '
1 or 2 = show ribbon
        End If
        ribbonheight = CommandBars("Ribbon").Controls(1).Height
        ribbonstate = (CommandBars("Ribbon").Controls(1).Height < 100)         '
under 100 means no commands
 
'Hide Ribbon if it is on the screen in 2010-2016
        If ribbonstate = vbFalse And iRibbon = 1 Then CommandBars.ExecuteMso
"MinimizeRibbon"
        If ribbonstate = vbTrue And iRibbon = 2 Then CommandBars.ExecuteMso
"MinimizeRibbon"
' yes - CommandBars.ExecuteMso "MinimizeRibbon seems to toggle minimize to max
and back

    End If
End If

End Sub



-----Original Message-----
From: AccessD
<accessd-bounces+jamesbutton=blueyonder.co.uk at databaseadvisors.com> On Behalf Of
Stuart McLachlan
Sent: Monday, March 20, 2023 9:28 AM
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] Screen Resolution

Your laptop should be running at its maximum resolution (something like 1366 x
768?) If 
that's the case, you can't increase its resolution.

The maximum resolution of any external monitor you connect will be limited by
connector 
type and GPU.  Typically, you may get up to 1920 × 1200 with a HDMI connection
and 
suitable monitor.


On 20 Mar 2023 at 3:48, Arthur Fuller wrote:

> Is it possible to change the screen resolution upon entry to an Access
> app, and then restore the original resolution on exit? The laptop I'm
> working on just doesn't have enough real estate to show the whole
> thing without scrollbars. On the client's machine there is no problem.
> But here at home on my laptop it's a PITA.
> 
> -- 
> Arthur
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 


-- 
AccessD mailing list
AccessD at databaseadvisors.com
https://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list