LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Screen Res change macro leaves me in VB Editor instead of work

KeepITCool,

I tried both versions - as you pointed out, the shorter one left the applet
behind the window, but with the longer solution, I STILL end up in the VB
editor!

Any more thoughts?

My worksheet is called "Database", here's what I have at the moment...

Cheers

Pete



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

'------------------------------------------------------------------------------
'2nd fix version
Dim dHandle#
dHandle = Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
AppActivate Application.Caption, True
Sheets("Database").Activate
AppActivate dHandle, False

'------------------------------------------------------------------------------
'1st fix
'Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
'AppActivate Application.Caption

'------------------------------------------------------------------------------
End If
End Sub


"keepITcool" wrote:

use
AppActivate Application.Caption

to get back to excel window.
problem may be that the cpl applet is then hidden
behind the excel window... :)

this should work:

If iConfirm = vbYes Then
Dim dHandle#
dHandle = Shell( _
"rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
AppActivate Application.Caption, True
Sheets(1).Activate
AppActivate dHandle, False
End If




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Peter Rooney wrote :

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 Sub
----------------------------------------------------------------------
---------------------- 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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Split Screen in VBA Editor BillCPA Excel Discussion (Misc queries) 3 April 27th 08 04:50 PM
mouse roll button doesn't work in VB editor Brettjg Excel Discussion (Misc queries) 9 May 17th 07 05:20 PM
Pivot table change leaves MSQuery open Ian Digby[_2_] Excel Programming 0 June 18th 04 09:53 AM
How to disable screen updating for the Visual Basic Editor llowwelll[_8_] Excel Programming 2 May 25th 04 02:58 AM
Scoll button in VBE editor; How make work? Chet Shannon Excel Programming 5 April 17th 04 01:45 AM


All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"