Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 11-11-2013, 06:21 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
Have you tried it?
You are missing my very first question. I do not want to just centre the page, but I'm trying zoom in to the level equivalent to "Fit Visible" (Ctrl+3) in adobe reader and then horizontally centre the page. It means the left and right margins of the page are not visible and you can see just the content of the page.

Your initial code is working perfectly, but just for small monitors. What I am trying to do now is to find the best zoom size according to the screen width, but I have no clue on how I can do it in vbscript. I reckon first step is to find the size of the screen.

Any idea?
Reply With Quote
  #17  
Old 11-11-2013, 09:38 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,963
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

Word is not Acrobat and you did not ask how you could:
Quote:
zoom in to the level equivalent to "Fit Visible" (Ctrl+3) in adobe reader and then horizontally centre the page
You asked:
Quote:
How can I relate this code to the size of the screen instead of a fix number
That is an entirely different question. Word does not have an exact 'equivalent to "Fit Visible" (Ctrl+3) in adobe reader'. Word has 'wdPageFitBestFit' or 'wdPageFitTextFit'. You choose which you want.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #18  
Old 11-11-2013, 09:42 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
Word is not Acrobat and you did not ask how you could:

You asked:

That is an entirely different question. Word does not have an exact 'equivalent to "Fit Visible" (Ctrl+3) in adobe reader'. Word has 'wdPageFitBestFit' or 'wdPageFitTextFit'. You choose which you want.

Please have a look at my first and second posts!
I understand that there is no "Fit Visible" in word, but I want to have a macro to do kind of similar.
The code you shared is doing this, but just for small monitors. How can one finds the size of the screen?
Reply With Quote
  #19  
Old 11-11-2013, 10:44 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,963
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

Your first and second posts were 5 months ago. To say:
Quote:
You are missing my very first question. I do not want to just centre the page, but I'm trying zoom in to the level equivalent to "Fit Visible" (Ctrl+3) in adobe reader
is quite untrue. Look at what you posted:
Quote:
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?
This has nothing to do with any notion of 'fit to screen'.

Sure you mentioned '"Fit Visible" (Ctrl+3) in adobe reader' in your second post, but that contradicts your first post. Furthermore, yesterday, you asked:
Quote:
How can I relate this code to the size of the screen instead of a fix number
That is what I responded to, not some self-contradictory postings from 5 months ago. You have now specified your requirements in three mutually-exclusive ways. If you cannot specify clearly and consistently what you want, don't expect any answers offered to match those requirements.
Quote:
I understand that there is no "Fit Visible" in word, but I want to have a macro to do kind of similar.
I have already told you what the nearest equivalents are that Word offers - 'wdPageFitBestFit' or 'wdPageFitTextFit'. Choose for yourself whichever best meets your needs.

Do remember that this forum is run entirely by volunteers, none of whom can be expected to invest a huge amount of effort into writing a macro that emulates Acrobat's "Fit Visible" function on a wide range of hardware. For starters, that presupposes the person doing the coding knows the intricacies of how Acrobat treats different kinds of content. And, even if one did, the different algorithms used by Word and Adobe can even lead to the same zoom factors giving magnifications, depending on the hardware used (see, for example, https://www.msofficeforums.com/word/...ord-100-a.html).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #20  
Old 11-12-2013, 08: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

Quote:
Originally Posted by macropod View Post
Your first and second posts were 5 months ago. To say:
Quote:
You are missing my very first question. I do not want to just centre the page, but I'm trying zoom in to the level equivalent to "Fit Visible" (Ctrl+3) in adobe reader
is quite untrue. Look at what you posted:
Quote:
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?
This has nothing to do with any notion of 'fit to screen'.

Sure you mentioned '"Fit Visible" (Ctrl+3) in adobe reader' in your second post, but that contradicts your first post. Furthermore, yesterday, you asked:
Quote:
How can I relate this code to the size of the screen instead of a fix number
That is what I responded to, not some self-contradictory postings from 5 months ago. You have now specified your requirements in three mutually-exclusive ways. If you cannot specify clearly and consistently what you want, don't expect any answers offered to match those requirements.
Quote:
I understand that there is no "Fit Visible" in word, but I want to have a macro to do kind of similar.
I have already told you what the nearest equivalents are that Word offers - 'wdPageFitBestFit' or 'wdPageFitTextFit'. Choose for yourself whichever best meets your needs.

Do remember that this forum is run entirely by volunteers, none of whom can be expected to invest a huge amount of effort into writing a macro that emulates Acrobat's "Fit Visible" function on a wide range of hardware. For starters, that presupposes the person doing the coding knows the intricacies of how Acrobat treats different kinds of content. And, even if one did, the different algorithms used by Word and Adobe can even lead to the same zoom factors giving magnifications, depending on the hardware used (see, for example, https://www.msofficeforums.com/word/18572-adobe-100-appears-larger-than-word-100-a.html).

You were referring to your code (which was 3.5 months after my first post!!!), so it means that you reviewed the previous posts!

I think you as an active member of this forum, whom I have seen and enjoyed answers' most of the time, should know that this is the way forums work. When a person leaves a question, he/she gets some feedback from other members. In response to those feedbacks, he/she does not repeat the whole question again and again and again! So, if another member wants to help, then he/she better quickly go through previous post and responds relatively, otherwise he/she is wasting the times of the other members.

Anyway, I should say that your answer was the best I got for this question and I appreciate it.
Reply With Quote
  #21  
Old 11-12-2013, 01:55 PM
fumei fumei is offline How to center a page horizontally? Windows 7 64bit How to center a page horizontally? Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Quote:
I reckon first step is to find the size of the screen.
I think disagree. The size is not the prime factor. It is screen resolution. I could be wrong, but I think for your purposes a 27" monitor running at 1024x768 would need something quite different from the same 27" running at 2560x2048. Maybe I am not understanding your posts - it would not be the first time I missed something.
Reply With Quote
  #22  
Old 11-12-2013, 03:02 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,963
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

Hi Gerry,

Yes, the screen size is irrelevant. And no, I don't believe you're missing anything. The OP's specifications have been quite inconsistent.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #23  
Old 11-12-2013, 05:56 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 fumei View Post
I think disagree. The size is not the prime factor. It is screen resolution. I could be wrong, but I think for your purposes a 27" monitor running at 1024x768 would need something quite different from the same 27" running at 2560x2048. Maybe I am not understanding your posts - it would not be the first time I missed something.

I think you are right! Thanks for this. So the question is that how one can find the display resolution in vbscript?

Or maybe the way is to find the left and right margins of the current document, and then find the width of the content. Also if we can find the width of the word windows that can display document (minus navigation pane). then we can find the zoom ratio fro any resolution and any word windows size! Am I right?
Reply With Quote
  #24  
Old 11-12-2013, 06:20 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,963
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

The display resolution is equally irrelevant, but if you really want to find out:
Code:
Private Declare Function GetSystemMetrics32 Lib "User32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
 
Sub GetMonitorInfo()
Dim h As Long, w As Long
h = GetSystemMetrics32(1) ' height in pixels
w = GetSystemMetrics32(0) ' width in pixels
MsgBox Format(w, "#,##0") & " wide * " & Format(h, "#,##0") & " high"
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #25  
Old 11-12-2013, 06:25 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
The display resolution is equally irrelevant, but if you really want to find out:
Code:
Private Declare Function GetSystemMetrics32 Lib "User32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
 
Sub GetMonitorInfo()
Dim h As Long, w As Long
h = GetSystemMetrics32(1) ' height in pixels
w = GetSystemMetrics32(0) ' width in pixels
MsgBox Format(w, "#,##0") & " wide * " & Format(h, "#,##0") & " high"
End Sub
I'll try this and let you know the result, but what is it that you think is relevant?
Reply With Quote
  #26  
Old 11-12-2013, 09: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,963
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

Well, for starters, how about the Word window size, whether the vertical ruler is showing, and so on.

Given how close Word's 'FitText' setting is to Acrobat's Ctrl-3 setting and the fact that the built-in options in both programs take account of all the variables, I do have to wonder why you'd even bother trying to second-guess what Acrobat will do via a Word macro...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #27  
Old 11-12-2013, 09:33 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

This is working! This as far as I tried, zoom in on the text and hide the margins, and also horizontally scroll to the middle, no matter to the size of the monitor, screen resolution and size of the word window whether it is full screen or not:

Code:
Sub test()
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 text fit
    .PageFit = wdPageFitTextFit
    'Get the full-screen zoom
  End With
  'Center the page
  .ActivePane.HorizontalPercentScrolled = 100
  .ActivePane.HorizontalPercentScrolled = .ActivePane.HorizontalPercentScrolled / 2
  'Restore the window now that we're finished
  .Visible = True
End With
End Sub
I couldn't find any way to scroll the page horizontally to the middle using just one line like this:
Code:
.ActivePane.HorizontalPercentScrolled=50
as 50% does not scroll it to the middle. To find out where is the middle, I first move it to the right, read the scroll percentage, and then scroll the page it to the half of what it was at the most right. Do you know a better way to do what these are doing:

Code:
  .ActivePane.HorizontalPercentScrolled = 100
  .ActivePane.HorizontalPercentScrolled = .ActivePane.HorizontalPercentScrolled / 2
Reply With Quote
  #28  
Old 11-12-2013, 09:38 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
Well, for starters, how about the Word window size, whether the vertical ruler is showing, and so on.

Given how close Word's 'FitText' setting is to Acrobat's Ctrl-3 setting and the fact that the built-in options in both programs take account of all the variables, I do have to wonder why you'd even bother trying to second-guess what Acrobat will do via a Word macro...

I just sent the code that I edited a little bit, but it seams to be working.
I defined a hotkey in word (F4) when I press it it shows the whole page, and when I press it again, it shows the bestfit. All I wanted is to bring it a bit closer and get rid of the margins. The code that I sent you does the job. But the thing is that I didn't realise wdPageFitTextFit option, maybe they just added in the latest version, am I right? (If not, I must missed this option which is doing the job) So all I did was that I used this option and managed to scroll the page to the centre.
Reply With Quote
  #29  
Old 11-12-2013, 09:58 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,963
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

Why don't you simply delete:
Code:
  'Center the page
  .ActivePane.HorizontalPercentScrolled = 100
  .ActivePane.HorizontalPercentScrolled = .ActivePane.HorizontalPercentScrolled / 2
As for:
Quote:
I didn't realise wdPageFitTextFit option, maybe they just added in the latest version, am I right?
Word has had that for over a decade.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #30  
Old 11-12-2013, 10:04 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

It does not scroll the page to the center just by itself. So I should scroll it to the center by those lines or any better way!
Reply With Quote
Reply



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 04:34 PM.


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