Resize & Positioning Excel Window

nupema

New Member
Joined
Oct 21, 2010
Messages
14
Hi,

I'm trying to resize and position one particular Excel workbook, and I made it work, but there is a problem, every excel file I open after this one, is opening in the same position and configuration (no bars, buttons, etc)


I used this code:

ThisWorkbook:
Code:
Sub Workbook_Open()
Application.EnableEvents = False
Call SetWindowSize
Application.EnableEvents = True
End Sub
Sub Workbook_Close()
Application.EnableEvents = False
Call SetWindowSizeClose
Application.EnableEvents = True
End Sub

Module 3:
Code:
Sub SetWindowSize()
    Application.WindowState = xlNormal
    Application.Top = 444
    Application.Left = 920
    Application.Width = 280
    Application.Height = 230
    ActiveWindow.DisplayHeadings = False
    ActiveWindow.DisplayGridlines = False
    Application.DisplayFormulaBar = False
    Application.ScreenUpdating = False
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
    Application.DisplayStatusBar = False
  
    'CommandBars.ExecuteMso "MinimizeRibbon"
    
End Sub

Module 4:
Code:
Sub SetWindowSizeClose()
Application.WindowState = xlNormal
 Application.Top = 150
    Application.Left = 300
    Application.Width = 800
    Application.Height = 600
    ActiveWindow.DisplayHeadings = True
    ActiveWindow.DisplayGridlines = True
    Application.DisplayFormulaBar = True
    Application.ScreenUpdating = True
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
    Application.DisplayStatusBar = True
End Sub

Module 5:
Code:
Sub Workbook_Open()
'On workbook open turn off scroll bars.
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With

End Sub

Module 5:
Code:
Sub Workbook_Close(Cancel As Boolean)
'Turn the scroll bars on before closing the workbook.
With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With
End Sub



I also found this other code, that for what I can understand, could also do the job, but I can't make it work at all... :(

Code:
Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ws As Worksheet
If ActiveSheet.Name = "BF" Then
Application.CommandBars("Worksheet Menu Bar").Enabled = False
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("NM").Visible = False
With ActiveWindow
        .DisplayHorizontalScrollBar = False
        .DisplayVerticalScrollBar = False
    End With
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = False
Else
Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.CommandBars("NM").Visible = True
With ActiveWindow
        .DisplayHorizontalScrollBar = True
        .DisplayVerticalScrollBar = True
    End With
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
End If
 
Application.DisplayAlerts = True
End Sub

Can anyone please help me? :rolleyes:
 
Andrew, it's solved!! I used your sample code and with some small modifications its working perfectly!!:biggrin:

Thank you very much for your help! ;)
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi, I know this thread is old. Sorry for that firstly. I want to resizing the workbook window when I Change Sheet1 to sheet2. Is there any way to do this?
 
Upvote 0

Forum statistics

Threads
1,216,748
Messages
6,132,492
Members
449,730
Latest member
SeanHT

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