+ Reply to Thread
Results 1 to 19 of 19

Restricting Window Size by Range

Hybrid View

  1. #1
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Restricting Window Size by Range

    I have created an electronic timesheet that is nearly complete. I have stripped the form of all toolbars, ribbons, etc that the user will not need. I would now like to restrict the window size of the entire workbook by range A1 through O31. I DO NOT want to prevent minimizing the document to the Taskbar, but I DO want to prevent resizing to include maximize.

    (see attached screenshot of my form at the size I want to restrict it to)
    Attached Images Attached Images
    Last edited by jonvanwyk; 12-20-2010 at 02:37 PM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Restricting Window Size by Range

    Sub snb()
        With ThisWorkbook.Sheets(1)
            .Columns(16).Resize(, Columns.Count - 15).Hidden = True
            .Rows(32).Resize(Rows.Count - 31).Hidden = True
            .ScrollArea = "A1:O31"
        End With
    End Sub



  3. #3
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Restricting Window Size by Range

    Quote Originally Posted by snb View Post
    Sub snb()
        With ThisWorkbook.Sheets(1)
            .Columns(16).Resize(, Columns.Count - 15).Hidden = True
            .Rows(32).Resize(Rows.Count - 31).Hidden = True
            .ScrollArea = "A1:O31"
        End With
    End Sub
    I attempted your solution and it seemed to have no affect. I have attached to this reply a screenshot of how I entered the code.
    Attached Images Attached Images

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Restricting Window Size by Range

    Why don't you put it into the workbook_open Event ?

  5. #5
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Restricting Window Size by Range

    Quote Originally Posted by snb View Post
    Why don't you put it into the workbook_open Event ?
    I have done this, and it is still not working (see attached screenshot)
    Attached Images Attached Images

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Restricting Window Size by Range

    You have my permission to adapt the code to your specific situation, e.g.

    With ThisWorkbook.Sheets("Menu")
      .Columns(16).Resize(, Columns.Count - 15).Hidden = True
      .Rows(32).Resize(Rows.Count - 31).Hidden = True
      .ScrollArea = "A1:O31"
    End With
    Code doesn't work when macros have been disabled.

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Restricting Window Size by Range

    Hi jonvanwyk
    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  8. #8
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Restricting Window Size by Range

    Quote Originally Posted by pike View Post
    Hi jonvanwyk
    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding
    I do not see where I have quoted whole posts, or created clutter. This post seems pretty straight forward to me. Also, I have had two different suggestions in the same post. If I do not quote, others might be confused which solution I am discussing. Rather than cost me "2 points", perhaps your energies can be better utilized in helping me solve my issue. Then I can mark it "solved" and move on :-)

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Restricting Window Size by Range

    Is this what you want? You need to adjust the sizes
    Option Explicit
    
    Sub resize()
    With Application
       .WindowState = xlNormal
       .Left = 450
       .Top = 1
       .Width = 750
       .Height = 300
    End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  10. #10
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Restricting Window Size by Range

    Quote Originally Posted by royUK View Post
    Is this what you want? You need to adjust the sizes
    Option Explicit
    
    Sub resize()
    With Application
       .WindowState = xlNormal
       .Left = 450
       .Top = 1
       .Width = 750
       .Height = 300
    End With
    End Sub
    I tried using the code above to no avail. Did I enter it incorrectly? (see attached) It tells me there is an issue with "Option Explicit" being between subs. My width will be 837 and the height 622. What does "Left" and "Top" represent?
    Attached Images Attached Images
    Last edited by jonvanwyk; 12-15-2010 at 11:34 AM.

  11. #11
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Restricting Window Size by Range

    Hi jonvanwyk
    You have quoted back every answer that you have received
    To post a reply use the Quick Reply window at the bottom of the thread.
    dont click on the Quote button

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Restricting Window Size by Range

    Hello jonvanwyk,

    I suspect you are not calling the macro either at the right time or in the right place. This code needs to be called in the UserForm's Activate event. Here is where you should place the call...
    Private Sub UserForm_Activate()
        Call RemoveMaximize Application.hWnd
    End sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Restricting Window Size by Range

    It's not necessary to quote whole posts, simply refer to the poster, we all have names.

    There's no point keep attaching images. We can't check what you are doing without the workbook

    You are receiving free help, so we expect you to follow our rules and any requests from moderators concerning your posts.
    Last edited by royUK; 12-16-2010 at 02:46 AM.

  14. #14
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Restricting Window Size by Range

    I have decided not to specify window size this way. Thank you for attempting to provide a solution. I will begin a new post with a different idea.

+ 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