+ Reply to Thread
Results 1 to 17 of 17

Reset Screen Resolution

Hybrid View

  1. #1
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Reset Screen Resolution

    Glad to help. Here's a before workbook close macro to add to the ThisWorkbook object:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Call ResetScreenResolution
    End Sub
    Then add this to your current module:
    Sub ResetScreenResolution(Optional Dummy As Integer)
         
        Dim x  As Long
        Dim y  As Long
        Dim MyMessage As String
        Dim MyResponse As VbMsgBoxResult
         
        x = Sheets("Sheet3").Range("A1").Value
        y = Sheets("Sheet3").Range("A2").Value
            MyMessage = "Your current screen resolution is " & x & " X " & y & vbCrLf _
            & vbCrLf & "Would you like to change your screen resolution now (you can change it back later, if you wish)?"
            MyResponse = MsgBox(MyMessage, vbExclamation + vbYesNo, "Screen Resolution")
    
        If MyResponse = vbYes Then
            Sheets("Sheet3").Range("A1").FormulaR1C1 = x
            Sheets("Sheet3").Range("A2").FormulaR1C1 = y
           
            Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
        End If
         
    End Sub
    Also, if that did the trick for you, please consider marking this thread solved:
    To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

    If you're so inclined, you could also add to my reputation by clicking the scales to the right of my user name
    Tom
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,065

    Re: Reset Screen Resolution

    Thanks Tom.

    I changed your code a little. See the completed code below. Thanks for all your help.
    Sub ResetScreenResolution(Optional Dummy As Integer)
         
        Dim x  As Long
        Dim y  As Long
        Dim MyMessage As String
        Dim MyResponse As VbMsgBoxResult
         
        x = Sheets("Sheet3").Range("A1").Value
        y = Sheets("Sheet3").Range("A2").Value
            MyMessage = "Your current screen resolution was originally " & x & " X " & y & vbCrLf _
            & vbCrLf & "Would you like to restore your original screen resolution now (you can change it later if you like)?"
            MyResponse = MsgBox(MyMessage, vbExclamation + vbYesNo, "Screen Resolution")
    
        If MyResponse = vbYes Then
            Sheets("Sheet3").Range("A1:A2").ClearContents       
            Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
        End If
         
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1