Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2013, 12:31 AM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default How to center a page horizontally?

I am trying to zoom in and then center the page by the following code but it doesn't work:

ActiveDocument.ActiveWindow.View.Zoom.Percentage = 250
ActiveWindow.ActivePane.HorizontalPercentScrolled = 50

Any idea?
Reply With Quote
  #2  
Old 06-13-2013, 05:28 PM
Charles Kenyon Charles Kenyon is offline How to center a page horizontally? Windows Vista How to center a page horizontally? Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Are you trying to change the view or are you trying to make the text vertically centered on the page?

Or, are you trying to get the insertion point to a particular spot in the document?
Reply With Quote
  #3  
Old 06-13-2013, 05:48 PM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default

I'm just trying to change the view!
Actually what I'm trying to achive is exactly equivalent to "Fit Visible" (Ctrl+3) in adobe reader.

Thanks in advance!
Reply With Quote
  #4  
Old 06-17-2013, 05:50 AM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default

any solution?
Reply With Quote
  #5  
Old 09-29-2013, 08:46 PM
macropod's Avatar
macropod macropod is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Possibly something like:
Code:
Sub Test()
Dim lZoom As Long
With ActiveWindow
  'Ignore any errors
  On Error Resume Next
  'Reduce flickering while changing settings
  .Visible = False
  'Switch to a single view pane
  .View.SplitSpecial = wdPaneNone
  'Switch to Print Preview mode
  .View.Type = wdPrintView
  With .ActivePane.View.Zoom
    'Set for a 1-page view
    .PageColumns = 1
    'Initialize for best fit
    .PageFit = wdPageFitBestFit
    'Get the full-screen zoom
    lZoom = .Percentage
    'Set zoom % to 250% min
    If .Percentage < 250 Then .Percentage = 250
  End With
  'Center the page
  .ActivePane.HorizontalPercentScrolled = (250 - lZoom) / 5
  'Restore the window now that we're finished
  .Visible = True
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 09-30-2013, 07:15 AM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default

Thanks for your reply, but it does not work!
Reply With Quote
  #7  
Old 09-30-2013, 01:32 PM
macropod's Avatar
macropod macropod is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Works for me ...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 09-30-2013, 05:02 PM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default

Could you explain the code a little bit? Especially .Percentage and lZoom and what they are defined for?
Reply With Quote
  #9  
Old 09-30-2013, 06:27 PM
macropod's Avatar
macropod macropod is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by b0x4it View Post
Could you explain the code a little bit? Especially .Percentage and lZoom and what they are defined for?
Did you read the comments in the code? I'd have thought they made it apparent what was going on.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 09-30-2013, 07:46 PM
Charles Kenyon Charles Kenyon is offline How to center a page horizontally? Windows Vista How to center a page horizontally? Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by macropod View Post
Works for me ...
On my laptop in Word 2010 it produces an overzoom to 250% when the correct zoom would be 150%.

When I substitute 150 for 250 throughout the procedure, it works on my machine.
Reply With Quote
  #11  
Old 09-30-2013, 09:54 PM
macropod's Avatar
macropod macropod is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I used 250% only because that's what b0x4it seems to require (see the first post in this thread).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 11-11-2013, 10:08 AM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Possibly something like:
Code:
Sub Test()
Dim lZoom As Long
With ActiveWindow
  'Ignore any errors
  On Error Resume Next
  'Reduce flickering while changing settings
  .Visible = False
  'Switch to a single view pane
  .View.SplitSpecial = wdPaneNone
  'Switch to Print Preview mode
  .View.Type = wdPrintView
  With .ActivePane.View.Zoom
    'Set for a 1-page view
    .PageColumns = 1
    'Initialize for best fit
    .PageFit = wdPageFitBestFit
    'Get the full-screen zoom
    lZoom = .Percentage
    'Set zoom % to 250% min
    If .Percentage < 250 Then .Percentage = 250
  End With
  'Center the page
  .ActivePane.HorizontalPercentScrolled = (250 - lZoom) / 5
  'Restore the window now that we're finished
  .Visible = True
End With
End Sub

This also works for me but just on my laptop with 15.1" monitor. It does nothing on my 27" monitor. How can I relate this code to the size of the screen instead of a fix number (250% in this code)?
Reply With Quote
  #13  
Old 11-11-2013, 02:16 PM
macropod's Avatar
macropod macropod is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by b0x4it View Post
This also works for me but just on my laptop with 15.1" monitor. It does nothing on my 27" monitor. How can I relate this code to the size of the screen instead of a fix number (250% in this code)?
Simple! Delete:
Code:
Dim lZoom As Long
and:
Code:
'Get the full-screen zoom
lZoom = .Percentage
'Set zoom % to 250% min
If .Percentage < 250 Then .Percentage = 250
and:
Code:
'Center the page
.ActivePane.HorizontalPercentScrolled = (250 - lZoom) / 5
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #14  
Old 11-11-2013, 03:35 PM
b0x4it b0x4it is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Advanced Beginner
How to center a page horizontally?
 
Join Date: May 2011
Posts: 95
b0x4it is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Simple! Delete:
Code:
Dim lZoom As Long
and:
Code:
'Get the full-screen zoom
lZoom = .Percentage
'Set zoom % to 250% min
If .Percentage < 250 Then .Percentage = 250
and:
Code:
'Center the page
.ActivePane.HorizontalPercentScrolled = (250 - lZoom) / 5
If you delete these codes, then how it scrolls horizontally to the centre?
Reply With Quote
  #15  
Old 11-11-2013, 04:47 PM
macropod's Avatar
macropod macropod is offline How to center a page horizontally? Windows 7 32bit How to center a page horizontally? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Have you tried it?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering text horizontally in powerpoint Microsoftenquirer1000 PowerPoint 0 10-28-2012 03:38 PM
How to Center One Line Vertically on Blank Page SQLUSA Word 1 08-29-2012 08:14 PM
Word doc that scroll horizontally Golfer4588 Word 1 03-22-2012 03:55 PM
How to center a page horizontally? Microsoft Word 2010 - Aligning table horizontally SWEngineer Word Tables 4 07-20-2011 01:32 AM
Labels will only print in center of page jferr Word 0 04-02-2010 09:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft