Screen Resolution?

dan2

Board Regular
Joined
Mar 26, 2002
Messages
60
Does anybody know if in VBA it is possible to make sure that on opening an excel document the screen resolution is set to say 800x600?

TIA

Dan
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try,

Sub GetScreenSize()
Dim x As Long, y As Long, sYourMessage, iConfirm As Integer
'x = GetSystemMetrics(SM_CXSCREEN)
'y = GetSystemMetrics(SM_CYSCREEN)
'If x< 1024 And y< 768 Then
'sYourMessage = "Current screen size is " & x & " x " & y & vbCrLf
sYourMessage = sYourMessage & "This screen is best viewed at 1024 x 768." & vbCrLf
sYourMessage = sYourMessage & "Would you like to change the resolution?"
iConfirm = MsgBox(sYourMessage, vbExclamation + vbYesNo, "Screen Resolution")
If iConfirm = vbYes Then
'Change screen settings
Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
End If
'End If
End Sub

Some systems may not like this code. I use it and most systems take it. JSW

PS. It works by prompting the user to set the resolution to what ever, then it pulls up the windows Display utility, so the user can slide the resolution over if needed. JSW
This message was edited by Joe Was on 2002-03-28 06:50
 
Upvote 0
You may also try:

Worksheets("Sheet1").PageSetup.Zoom = 80

To set the sheet zoom to 80%. JSW
 
Upvote 0
Works well thanks Joe

Is there a way of just setting the resolution to avoid the screen settings requester coming on the screen?

Thanks

Dan
 
Upvote 0
Some time ago I did a macro that on open, got the current display resolution, comepaired it to the resolution wanted and if different saved the original resolution and set the current resolution to the resolution wanted. Then on exit it got the saved resolution and reset the current resolution to the original saved resolution.

I looked for the code but it must be on another system or I lost it. I cannot remember the trick to setting the resolution directly? JSW
 
Upvote 0
On 2002-03-28 17:11, dan2 wrote:
Works well thanks Joe

Is there a way of just setting the resolution to avoid the screen settings requester coming on the screen?

Thanks

Dan

Hi Dan
Here is a routine i got together that does
as Joe has said
ie. Changes scrn resolution open open then
restores upon close....had a bit of
trouble restoring the taskbar and app.wnd
but found a fix.

I could have placed the settings on a worksheet but opted to Keep the old values
in a variable via a Class Module.

You will need
1) Class module named cScreen
2) A std module
3) An entry in the Thisworkbook object

Here they are;

<font face=Courier New><SPAN style="color:darkblue">Option</SPAN> <SPAN style="color:darkblue">Explicit</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Workbook_BeforeClose(Cancel <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>)
Application.Run ("Restore_Scrn")
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Workbook_Open()
Application.Run ("Set_Scrn")
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>



<SPAN style="color:green">'2)</SPAN>

Option Explicit
<SPAN style="color:green">'// Keep Old settings here</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'=========================</SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Public</SPAN> dIniScrnW <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Double</SPAN>
<SPAN style="color:darkblue">Public</SPAN> dIniScrnH <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Double</SPAN>
<SPAN style="color:darkblue">Public</SPAN> nDC       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'=========================</SPAN></SPAN></SPAN>

<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'//>></SPAN></SPAN></SPAN> Added Const to handle Update</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> WM_DISPLAYCHANGE = &H7E
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> HWND_BROADCAST = &HFFFF&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> BITSPIXEL = 12

<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'//>></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> EWX_LOGOFF = 0
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> EWX_SHUTDOWN = 1
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> EWX_REBOOT = 2
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> DM_PELSWIDTH = &H80000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> DM_PELSHEIGHT = &H100000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> CDS_UPDATEREGISTRY = &H1
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> CCDEVICENAME = 32
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> CDS_TEST = &H4
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> DISP_CHANGE_SUCCESSFUL = 0
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> DISP_CHANGE_RESTART = 1
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> CCFORMNAME = 32

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> typDevMODE
    dmDeviceName       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN> * CCDEVICENAME
    dmSpecVersion      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmDriverVersion    <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmSize             <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmDriverExtra      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmFields           <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
    dmOrientation      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmPaperSize        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmPaperLength      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmPaperWidth       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmScale            <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmCopies           <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmDefaultSource    <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmPrintQuality     <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmColor            <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmDuplex           <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmYResolution      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmTTOption         <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmCollate          <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmFormName         <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN> * CCFORMNAME
    dmUnusedPadding    <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmBitsPerPel       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
    dmPelsWidth        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
    dmPelsHeight       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
    dmDisplayFlags     <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
    dmDisplayFrequency <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" _
    (<SPAN style="color:darkblue">ByVal</SPAN> lpszDeviceName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> iModeNum <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, lptypDevMode <SPAN style="color:darkblue">As</SPAN> Any) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>



<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> ChangeDisplaySettings Lib "user32" Alias _
    "ChangeDisplaySettingsA" (lptypDevMode <SPAN style="color:darkblue">As</SPAN> Any, <SPAN style="color:darkblue">ByVal</SPAN> dwFlags <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> ExitWindowsEx Lib "user32" (<SPAN style="color:darkblue">ByVal</SPAN> uFlags <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, _
   <SPAN style="color:darkblue">ByVal</SPAN> dwReserved <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>


<SPAN style="color:green">'// >>Added these API to fix screen update</SPAN>

<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> SendMessage Lib "user32" Alias "SendMessageA" _
    (<SPAN style="color:darkblue">ByVal</SPAN> hwnd <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> wMsg <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> wParam <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, lParam <SPAN style="color:darkblue">As</SPAN> Any) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> GetDeviceCaps Lib "gdi32" (<SPAN style="color:darkblue">ByVal</SPAN> hdc <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> nIndex <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> CreateDC Lib "gdi32" Alias "CreateDCA" (<SPAN style="color:darkblue">ByVal</SPAN> lpDriverName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> lpDeviceName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> lpOutput <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> lpInitData <SPAN style="color:darkblue">As</SPAN> Any) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> DeleteDC Lib "gdi32" (<SPAN style="color:darkblue">ByVal</SPAN> hdc <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Sub</SPAN> ChangeScreen_Resol(dScrnW <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Double</SPAN>, dScrnH <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Double</SPAN>)
<SPAN style="color:darkblue">Dim</SPAN> typDevM <SPAN style="color:darkblue">As</SPAN> typDevMODE
<SPAN style="color:darkblue">Dim</SPAN> lResult <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> iAns <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>

<SPAN style="color:green">'// Retrieve info about the current graphics mode</SPAN>
<SPAN style="color:green">'// on the current display device.</SPAN>
<SPAN style="color:green">'// Note: Declared All Types</SPAN>
<SPAN style="color:green">'// other wise the Excel will crash</SPAN>
lResult = EnumDisplaySettings(0, 0, typDevM)

<SPAN style="color:green">'// Set the new resolution.</SPAN>
<SPAN style="color:darkblue">With</SPAN> typDevM
    .dmFields = DM_PELSWIDTH <SPAN style="color:darkblue">Or</SPAN> DM_PELSHEIGHT
    .dmPelsWidth = dScrnW  <SPAN style="color:green">'=800  'ScreenWidth  (640,800,1024, etc)</SPAN>
    .dmPelsHeight = dScrnH <SPAN style="color:green">'=600  'ScreenHeight (480,600,768, etc)</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>

<SPAN style="color:green">'// Change the display settings to the specified graphics mode.</SPAN>
lResult = ChangeDisplaySettings(typDevM, CDS_TEST)
<SPAN style="color:darkblue">Select</SPAN> <SPAN style="color:darkblue">Case</SPAN> lResult
    <SPAN style="color:darkblue">Case</SPAN> DISP_CHANGE_RESTART
        iAns = MsgBox("You must restart your computer <SPAN style="color:darkblue">To</SPAN> apply these changes." & _
            vbCrLf & vbCrLf & "Do you want <SPAN style="color:darkblue">To</SPAN> restart now?", _
            vbYesNo + vbSystemModal, "Screen Resolution")
        <SPAN style="color:darkblue">If</SPAN> iAns = vbYes <SPAN style="color:darkblue">Then</SPAN> <SPAN style="color:darkblue">Call</SPAN> ExitWindowsEx(EWX_REBOOT, 0)
    <SPAN style="color:darkblue">Case</SPAN> DISP_CHANGE_SUCCESSFUL
        <SPAN style="color:darkblue">Call</SPAN> ChangeDisplaySettings(typDevM, CDS_UPDATEREGISTRY)
        <SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'//>></SPAN></SPAN></SPAN> Fixed screen taskbar here! thanks to API net</SPAN>
        <SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'//>></SPAN></SPAN></SPAN> Notify all the windows of the screen resolution change</SPAN>
        <SPAN style="color:darkblue">Dim</SPAN> lScInfo <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, lBits <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
        lScInfo = dScrnW * 2 ^ 16 + dScrnH
        nDC = CreateDC("DISPLAY", vbNullString, vbNullString, <SPAN style="color:darkblue">ByVal</SPAN> 0&)
        lBits = GetDeviceCaps(nDC, BITSPIXEL)
        SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, <SPAN style="color:darkblue">ByVal</SPAN> lBits, <SPAN style="color:darkblue">ByVal</SPAN> lScInfo
    <SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Else</SPAN>
        MsgBox "An error occured trying to set the display!"
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Select</SPAN>


<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>



<SPAN style="color:darkblue">Sub</SPAN> ClrD()
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'delete our device context</SPAN></SPAN></SPAN>
DeleteDC nDC
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>

<SPAN style="color:green">'1)</SPAN>

Option Explicit
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> The GetSystemMetrics function retrieves various system metrics</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> and system configuration settings. System metrics are the dimensions</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> (widths and heights) of Windows display elements.</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> All dimensions retrieved by GetSystemMetrics are in pixels.</SPAN>
<SPAN style="color:darkblue">Private</SPAN> Declare <SPAN style="color:darkblue">Function</SPAN> GetSystemMetrics Lib "user32.dll" (<SPAN style="color:darkblue">ByVal</SPAN> nIndex <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> SM_CXSCREEN = 0
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> SM_CYSCREEN = 1
<SPAN style="color:darkblue">Dim</SPAN> oScrn <SPAN style="color:darkblue">As</SPAN> cScreen <SPAN style="color:green">'Reference the New Class</SPAN>


<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Set_Scrn()
<SPAN style="color:green">'// Note: On some systems the Taskbar may need to be Reset/Repositioned</SPAN>
<SPAN style="color:green">'// do this manually by selecting and moving to the side and then</SPAN>
<SPAN style="color:green">'// moving back.</SPAN>
<SPAN style="color:green">'// Will look into a fix for this</SPAN>
<SPAN style="color:green">'// Fixed this Thanks to API net</SPAN>
<SPAN style="color:green">'// See >></SPAN>



<SPAN style="color:darkblue">On</SPAN> <SPAN style="color:darkblue">Error</SPAN> <SPAN style="color:darkblue">GoTo</SPAN> Ex
<SPAN style="color:green">'// Create a New instance of Class to reference</SPAN>
<SPAN style="color:darkblue">Set</SPAN> oScrn = <SPAN style="color:darkblue">New</SPAN> cScreen
<SPAN style="color:darkblue">With</SPAN> oScrn
    .dIniScrnH = GetSystemMetrics(SM_CYSCREEN) <SPAN style="color:green">'600</SPAN>
    .dIniScrnW = GetSystemMetrics(SM_CXSCREEN) <SPAN style="color:green">'800</SPAN>
    <SPAN style="color:darkblue">If</SPAN> .dIniScrnH <> 600 <SPAN style="color:darkblue">Or</SPAN> .dIniScrnW <> 800 <SPAN style="color:darkblue">Then</SPAN>
        <SPAN style="color:darkblue">Call</SPAN> .ChangeScreen_Resol(800, 600)
    <SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>

Ex:
Application.WindowState = xlMaximized

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>



<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Restore_Scrn()
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> Always restore back to the users</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> Original Screen settings !</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' //</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> Incase of Error leave everything Alone</SPAN>
<SPAN style="color:darkblue">On</SPAN> <SPAN style="color:darkblue">Error</SPAN> <SPAN style="color:darkblue">Resume</SPAN> <SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">Call</SPAN> oScrn.ChangeScreen_Resol(oScrn.dIniScrnW, oScrn.dIniScrnH)
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'delete our device context</SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Call</SPAN> oScrn.ClrD
Application.WindowState = xlMaximized
<SPAN style="color:darkblue">On</SPAN> <SPAN style="color:darkblue">Error</SPAN> <SPAN style="color:darkblue">GoTo</SPAN> 0
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>

</FONT>
If this is not clear then I can send workbook
 
Upvote 0
Ivan,

Do you still have this workbook? I seem to be having the same problem everytime I click on a link that opens an excel workbook and generates a graph using macros.
 
Upvote 0

Forum statistics

Threads
1,213,485
Messages
6,113,931
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top