P
Peter Rooney
Good morning all!
I'm running the following code, to allow users to change the screen
resolution
--------------------------------------------------------------------------------------------
Option Explicit
Private Declare Function GetSystemMetrics Lib "user32.dll" ( ByVal nIndex
As Long) _As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Sub ScreenResolutionSub()
Dim x As Long, y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)
sYourMessage = "Your current screen size is " & x & " X " & y & vbCrLf & _
"Would you like to change the resolution?"
iConfirm = MsgBox(sYourMessage, vbExclamation + vbYesNo, "Screen
Resolution")
If iConfirm = vbYes Then
Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
Sheets("Database").Activate
End If
End Su
--------------------------------------------------------------------------------------------
It works fine (I didn't write it, so I can't claim the credit), but I end up
with the the VB editor screen displayed, even though I'm in a worksheet when
I run the macro.
Can anyone tell me the VBA to go back into Excel (i.e the equivalent of
Alt-F11) ?
Thanks in advance
Pete
I'm running the following code, to allow users to change the screen
resolution
--------------------------------------------------------------------------------------------
Option Explicit
Private Declare Function GetSystemMetrics Lib "user32.dll" ( ByVal nIndex
As Long) _As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Sub ScreenResolutionSub()
Dim x As Long, y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)
sYourMessage = "Your current screen size is " & x & " X " & y & vbCrLf & _
"Would you like to change the resolution?"
iConfirm = MsgBox(sYourMessage, vbExclamation + vbYesNo, "Screen
Resolution")
If iConfirm = vbYes Then
Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
Sheets("Database").Activate
End If
End Su
--------------------------------------------------------------------------------------------
It works fine (I didn't write it, so I can't claim the credit), but I end up
with the the VB editor screen displayed, even though I'm in a worksheet when
I run the macro.
Can anyone tell me the VBA to go back into Excel (i.e the equivalent of
Alt-F11) ?
Thanks in advance
Pete