Consulting

Results 1 to 19 of 19

Thread: Solved: Word paragraph position

  1. #1

    Solved: Word paragraph position

    Hi, how it's possible to check if a paragraph is positioned at the beginning
    of a page/column?
    Thank you
    Pino

  2. #2
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    Hi and welcome at VBAX.

    Checking whether the paragraph is the first on a page should work with this function, which checks whether the selected paragraph is the 1st one:

    [VBA]
    Sub TestPar()
    If Selection.Information(wdFirstCharacterLineNumber) = 1 Then MsgBox "1st on Page!"
    End Sub

    [/VBA]

    Daniel

  3. #3
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    About the 1st of a column I thougt of something like

    [VBA]

    ? selection.Paragraphs(1).Range.Characters(1).Information(wdVerticalPositionR elativeToPage)

    [/VBA]

    to check whether the beginning of the paragraph is at the top of the document, but there seems to be a problem because the manual column feed seems to be included, and this one is at the end of the last column.
    So I'm not sure how to check this...

    Daniel

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by pinovasa
    Hi, how it's possible to check if a paragraph is positioned at the beginning
    of a page/column?
    Thank you
    Pino
    Hi & Welcome to VBAX!

    Finding out where the insertion point is in a document is always a difficult question to answer in general.

    So could you please expand on what you are trying to do whit as much detail as possible.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  5. #5
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Actually Joost....the question was how to tell if a paragraph is at the top of a page/column, NOT the insertion (ahem...Selection) point. The Selection point could be anywhere.

    Unless....that IS the real question.

    Pino, are you asking if the paragraph the Selection point is in, is at the top of the page? Or are you asking if any given paragraph is at the top of the page?

  6. #6
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    Right, it is about the paragraph (I understood it that way, too). But for testing purposes (and since I don't know Pino's going to determine the paragraph he wants to check), I simply used the selection.
    But since both, Selection and Paragraph are actually just Ranges, this should not matter too much.

    Daniel

  7. #7
    Thank you, Daniel!

  8. #8
    I need to space blocks o text (for a book of abstracts) formatted in two columns. Keeping togheter the various paragraphs of the abstract, I want to automate the job of inserting the same amount of blank space beetween the two or tree abstracts of a column, so that the first line of the first abstract and the last line of the second (or third one) are positioned at the beginning and the end of each column. (And I would'nt use a paginating softare...)
    Thank you all
    Pino

  9. #9
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    This is still confusing. What do you mean by "end of each column"? What is defining the end? Do you mean something like:

    Abstract 1 Abstract 2
    Abstract 1 Abstract 2
    Abstract 1 Abstract 2
    Abstract 1 Abstract 2
    Abstract 2
    Abstract 2
    Abstract 2

    Abstract 3 Abstract 4
    Abstract 3 Abstract 4
    Abstract 3 Abstract 4
    Abstract 3
    Abstract 3

    Abstract 5 Abstract 6
    Abstract 5 Abstract 6
    Abstract 5 Abstract 6

    Please clarify how you are making, or defining, the "beginning" and "end" of the columns.

    It seems to me that columns may not be the best thing for you.

  10. #10
    This is my need:

    Header1 Header2
    --------------------
    Abstract1 Abstract3 Top of columns
    Abstract1 Abstract3
    Abstract1 Abstract3
    Abstract1

    Abstract4
    Abstract4
    Abstract2
    Abstract2
    Abstract2 Abstract5
    Abstract2 Abstract5
    Abstract2 Abstract5 Bottom of columns
    --------------------
    Page n.

    For "beginning" i mean the top and for end the bottom of the column.
    Thanks a lot
    Pino

  11. #11
    Sorry, but Abstract4 must be right justified!
    (Probably the editor eliminates white spaces..)
    Pino

  12. #12
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    Are these columns in a table

  13. #13
    LHeader......RHeader
    --------------------
    Abstract1..Abstract3
    Abstract1...............
    ............................
    ...............Abstract4
    ...............Abstract4
    Abstract2...............
    Abstract2...............
    Abstract2..Abstract5
    Abstract2..Abstract5
    Abstract2..Abstract5 Bottom of columns
    --------------------
    .........Page n..........

    (Dot = Blank)
    Sorry for my annoiance...
    Pino

  14. #14
    Daniel, I would prefer not to use tables, but insert preformatted abstract files
    using a VBA macro.
    Pino

  15. #15
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Sorry, I must be very senile. I thought I had asked how you define the beginning and end of the columns.

    So. How do you define the beginning and end of columns?

    Are you saying in your example that this will ALWAYS fit on one page?

    Are you breaking the columns for anothe page?

    I will tell you right now, if you are considering this as a flowing column, where the text moves down and across into the other column.....it would take extremely tricky coding to do what you seem to be asking. You would have to do serious calculations of the ranges for each paragraph in order to get them lined up.

    Why not just use a table? It would be much easier, if automation is what you want. If columns are what you need however, then good luck. It could be done, but it would not be trivial.

  16. #16
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Timing is off. OK. You certainly can do what you ask as columns manually. However, unless those abstracts are all the same length....you are out of luck, in terms of an easy solution.

    Remember that your LHeader and RHeader are not true headers. There is no real "right" column. At least not unless you insert a column break. Otherwise the text fills the left column first.

    So you are asking Word to anticipate where a paragraph will be. Word can NOT do this. You will have to do the insertion of text, then calculate where the beginnings and end are, then shift things around. I can not see how you could error trap this so well that there would not be...well, errors. Things not lining correctly. You could get it close, but I can pretty much say that unless you have thousands and thousands of these, the effort to code it would take MUCH longer than to do it all manually.

    But hey, I have a test document going, and I am working on it. Maybe I will prove myself wrong. Maybe someone else will come up with something really cool.

  17. #17
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by fumei
    Actually Joost....the question was how to tell if a paragraph is at the top of a page/column, NOT the insertion (ahem...Selection) point. The Selection point could be anywhere.
    Hi Gerry,

    True and I have the same defense as Daniel!
    But my main answer was the fact that it's hard to follow the flow of filling text over multiple pages.

    And I need a lot more detail to give a good answer .... therefore I'm still not sure what the true question is. (And neither are you if I read you correct)

    Later..
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  18. #18
    My constraints are that an abstract must not split beetween columns
    or pages, and one blank space must stay between two abstracts
    (or two equal spaces beetween tree abstracts).
    So, which is your suggestion using tables?

  19. #19
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    1. First constraint: abstract must not be split between columns, or pages.

    Response: Unless you can absolutely make sure the text contents are not longer than one page column, this is literally impossible. If the the text is longer than one page column, then it WILL split. There is nothing you can do about it. If the amount of text is bigger than the space it can fit into...it makes more space, which means it splits into another column or page.

    So can you be absolutely sure of this. If so, confirm.

    2. How many abstract going into a document? If there only going to be, say 6, and they can fit all on one page, this does not raise too many problems. If you are talking 20, where there are going to HAVE to be multiple pages, then you will have to use Sections breaks to close the columns, then restart them again on a new page.

    I believe this is the third of fourth time I have asked. How are you defining the end of columns. I also think I asked previously about if they are going to be on one page.

    You have to clearly state your needs. Precisely. If you do NOT need more than one page you must state this. If you DO need more than one page you must state this.

    I will also say again, while it may be possible to automate this, I really think it is probably not worth the effort.

    Let me see if I can explain why.

    Abstract 1 = 523 characters
    Abstract 2 = 719 characters
    Abstract 3 = 495 characters
    Abstract 4 = 678 characters

    To make this work you HAVE TO:

    1. Calculate the number of characters in each abstract
    2. Determine the total number of characters that will fit into a column
    3. Adjust the range (the number of characters) of EACH abstract to dynamically fit into the columns.

    So say you determine ONE column (from top of page to bottom) is 1423 characters...I am making this up. You will actually have to count it. And THAT will depend on the style (font size) you are using. BTW: if you are not using proper Styles....walk away...you will have a total nightmare on your hands without using proper styles.

    OK, so

    523 characters + 719 characters = 1242 characters. Balance = 181 characters. Not enough to fit Abstract 3.

    So after Abstract 1 is inserted, then Abstract 2, you have to insert a Column break - this forces the right column. Anstract 3 = 495 characters. But Abstract 1 (beside it) is taking up 523 characters.

    You can either add 28 blank characters after Abstract 3 - which moves the "end of it to equal the end of Abstract 1; OR claculate how many characters it takes to fill across the column and then calculate how many paragraphs of the style you are using to fill the distance down.

    Are you getting this? It CAN be done, but is it worth it? I mentioned this previously - unless you have MANY of these to do, it would be faster to do it manually, because you can SEE, with your eyes, if it is fitting. Word can not see anything. You have to actually make it count the characters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •