PDA

View Full Version : Solved: Word paragraph position



pinovasa
07-12-2005, 04:14 AM
Hi, how it's possible to check if a paragraph is positioned at the beginning
of a page/column?
Thank you
Pino

Steiner
07-12-2005, 05:08 AM
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:


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



Daniel

Steiner
07-12-2005, 05:14 AM
About the 1st of a column I thougt of something like



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



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

MOS MASTER
07-12-2005, 07:04 AM
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! :hi:

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. :whistle:

fumei
07-12-2005, 11:55 PM
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?

Steiner
07-13-2005, 12:56 AM
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

pinovasa
07-13-2005, 03:51 AM
Thank you, Daniel!

pinovasa
07-13-2005, 04:26 AM
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

fumei
07-13-2005, 05:06 AM
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.

pinovasa
07-13-2005, 05:54 AM
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

pinovasa
07-13-2005, 06:01 AM
Sorry, but Abstract4 must be right justified!
(Probably the editor eliminates white spaces..)
Pino

Steiner
07-13-2005, 06:03 AM
Are these columns in a table:confused:

pinovasa
07-13-2005, 06:10 AM
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

pinovasa
07-13-2005, 06:13 AM
Daniel, I would prefer not to use tables, but insert preformatted abstract files
using a VBA macro.
Pino

fumei
07-13-2005, 06:14 AM
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.

fumei
07-13-2005, 06:23 AM
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.

MOS MASTER
07-13-2005, 06:26 AM
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, :yes

True and I have the same defense as Daniel! :rofl:
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..:whistle:

pinovasa
07-13-2005, 06:31 AM
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?

fumei
07-18-2005, 09:51 AM
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.