Full size window

F

Francis Hookam

Word 2001

In XL, to maximise the window but leaving 100 pixels at the right side and
50 at the bottom to leave a view of the desktop, I use

Public Sub FullSizeWindow()
Application.ScreenUpdating = False
Const FREERIGHT = 100
Const FREEBOTTOM = 50
ActiveWindow.WindowState = xlMaximized
ActiveWindow.Height = ActiveWindow.Height - FREEBOTTOM
ActiveWindow.Width = ActiveWindow.Width - FREERIGHT
End Sub

Copying the macro into Word and it runs but simple makes the window smaller
by 100x50 each time. This seems to be because

ActiveWindow.WindowState = xlMaximized

does not work in Word as it does in XL

Is there a Word instruction to enlarge the window to the size of the screen
- the zoom box merely toggles between some predetermined width, which is not
wide enough, and full depth?

Thank you

Francis Hookham
 
J

JE McGimpsey

Francis Hookam said:
Word 2001

In XL, to maximise the window but leaving 100 pixels at the right side and
50 at the bottom to leave a view of the desktop, I use

Public Sub FullSizeWindow()
Application.ScreenUpdating = False
Const FREERIGHT = 100
Const FREEBOTTOM = 50
ActiveWindow.WindowState = xlMaximized
ActiveWindow.Height = ActiveWindow.Height - FREEBOTTOM
ActiveWindow.Width = ActiveWindow.Width - FREERIGHT
End Sub

Copying the macro into Word and it runs but simple makes the window smaller
by 100x50 each time. This seems to be because

ActiveWindow.WindowState = xlMaximized

does not work in Word as it does in XL

Is there a Word instruction to enlarge the window to the size of the screen
- the zoom box merely toggles between some predetermined width, which is not
wide enough, and full depth?

Note that xlMaximized is an XL constant, not a Word constant, so it
wouldn't work in any case. The mechanics are a bit different in the Word
Object Model, too. Here's one way:

Public Sub FullSizeWindow()
Const FREERIGHT As Long = 100
Const FREEBOTTOM As Long = 50
Dim nMyHeight As Long
Dim nMyWidth As Long
With Application
.ScreenUpdating = False
nMyHeight = .UsableHeight - FREEBOTTOM
nMyWidth = .UsableWidth - FREERIGHT
With ActiveWindow
.WindowState = wdWindowStateNormal
.Height = nMyHeight
.Width = nMyWidth
End With
.ScreenUpdating = True
End With
End Sub

Note that Word/VBA Help says that the .WindowState property is not
supported on the Mac (at least in Word04 - I think it's the same in
other versions, but I didn't check). This is demonstrably false - the
WindowState property returns the appropriate values for maximized,
minimized and normal. (I'm working on a bug report, but this post
*should* get the attention of MacBU).

Moreover, in order to directly set the window's height/width, the
ActiveWindow's .WindowState property needs to be set at
wdWindowStateNormal (which is equivalent to 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top