Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2025, 11:40 PM
Bikram Bikram is offline Measuring Positions in msword Windows 10 Measuring Positions in msword Office 2007
Advanced Beginner
Measuring Positions in msword
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Post Measuring Positions in msword

Hello and Greetings,
I am developing a program in python using (pywin32) and using msword 2007 for automatically adjsting formatting for paragraphs based on its attributes. For which i require postion of paragraph.range. I am using paragraph.range.information(wdverticalpositionrela tivetopage) but it is not accurate because it is returning the correct position for page one and returning 72.5 for every paragraph in second page with few exceptions.
I would like to know if there are other ways to access vertical and horizontal positions?
Reply With Quote
  #2  
Old 07-03-2025, 01:23 AM
macropod's Avatar
macropod macropod is offline Measuring Positions in msword Windows 10 Measuring Positions in msword Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,465
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

Without seeing your code, no-one will be able to help you. Besides which, this forum is for VBA, not python, and I don't know how often people proficient in python visit this page.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-03-2025, 01:47 AM
Bikram Bikram is offline Measuring Positions in msword Windows 10 Measuring Positions in msword Office 2007
Advanced Beginner
Measuring Positions in msword
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Default

First of all Thank you for replying.
I was using the following code to test the vertical Position but it returned correct position of paragraphs for one page and returned 72.5 for all paragraphs of another page and also got the same result from python code. I also discovered that when a cell of a table is selected and Selection.Range.Information(wdVerticalPositionRela tiveToPage) is executed than also wdVerticalPositionRelativeToPage would give position relative to that table and not page. So, I was wondering that is there something that i am missing or is it a bug?
Code:
Sub GetParagraphVerticalPositionsWithSelection()
    Dim para As paragraph
    Dim vertPos As Single
    For Each para In ActiveDocument.Paragraphs
        para.Range.Select
        vertPos = Selection.Range.Information(wdVerticalPositionRelativeToPage)
        Debug.Print ("Paragraph: " & para.Range.text & "Vertical Position: " & vertPos)
    Next para
End Sub
Reply With Quote
  #4  
Old 07-03-2025, 02:13 AM
macropod's Avatar
macropod macropod is offline Measuring Positions in msword Windows 10 Measuring Positions in msword Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,465
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

There is no need to select anything. For example:
Code:
Sub GetParagraphVerticalPositions()
Dim para As Paragraph, vertPos As Single
For Each para In ActiveDocument.Paragraphs
  vertPos = para.Range.Information(wdVerticalPositionRelativeToPage)
  MsgBox ("Paragraph: " & para.Range.Text & "Vertical Position: " & vertPos)
Next para
End Sub
Works for me...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 08-01-2025, 01:07 AM
Bikram Bikram is offline Measuring Positions in msword Windows 10 Measuring Positions in msword Office 2007
Advanced Beginner
Measuring Positions in msword
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Default

Thank you Paul.... The problem seems to be in my document rather than word.
Reply With Quote
Reply

Tags
vertical postion



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why my watermark are placed in different positions in some pages? shanlau Word VBA 2 12-04-2018 01:51 AM
Page numbers in different positions NugentS Word 3 12-04-2018 01:24 AM
Visio Pro 2016: Measuring the total length of a series of interconnected lines busander Visio 3 07-11-2017 09:53 AM
Measuring Turnaround Time quirkycanuck Outlook 0 03-03-2015 01:22 PM
Using MSWord 2003 docs in MSWord 2010 Joe Watson Word 7 05-31-2014 11:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:44 PM.


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