find page break and the column where I am in word VBA

Hi...
I am generating a word document using VBA.

The document is in the format of two columns every page.

The data should fill the first column till the end of the first page and then should fill the second column till the end of the first page and then should go to the first column of the second page and then second column in the second page.......like that..

Here I need to locate the page break(when I reach the end of every page) and the column where I am(either in the first column or second column)...so that...the data can traverse as said above...

can anyone help me in this.
amiteshsinhaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
It should be all automatic. Just select the text and go to Format/Columns and choose Two.
Columns like that are sometimes called 'snaking columns'
0
GrahamSkanRetiredCommented:
Sorry, just seen the VBA bit.
0
GrahamSkanRetiredCommented:
This will do it in VBA
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

GrahamSkanRetiredCommented:
Sorry, I mean this:
It will do the first section only.
Sub TwoCols()
    With ActiveDocument.Sections(1).PageSetup.TextColumns
        .SetCount NumColumns:=2
        .EvenlySpaced = True
        .LineBetween = False
        .Width = CentimetersToPoints(6.7)
        .Spacing = CentimetersToPoints(1.25)
    End With
End Sub

To do the whole document, change th With line to this:
   With ActiveDocument.PageSetup.TextColumns

0
amiteshsinhaAuthor Commented:
Hi...I've already added table/columns...I need answer for this....

***************
Here I need to locate the page break(when I reach the end of every page) and the column where I am(either in the first column or second column)...so that...the data can traverse as said above...
****************
0
AntonioPCommented:
How are you generating this document? Can you describe your VBA a little?  I don't understand why the data is not snaking through the columns automatically.
0
amiteshsinhaAuthor Commented:
I am getting the data dynamically and putting it in the first column of the table like this...

with wrdApp.Selection
        .Tables.Add wrdApp.Selection.Range, NumRows:=1, NumColumns:=2
        .MoveLeft unit:=wdCell

        .TypeParagraph
        .TypeText Text:="Feature ONE"
     
        .TypeParagraph
        .TypeText Text:="Bullet One"

        .TypeParagraph
        .TypeText Text:="Bullet Two"

        .TypeParagraph
        .TypeText Text:="Feature TWO"
     
        .TypeParagraph
        .TypeText Text:="Bullet One"

        .TypeParagraph
        .TypeText Text:="Bullet Two"


and when the end of the page comes..it should go to the next(second) column of the table in the same page. It should not go to the first column of the second page. Likewise when it is done with the second column of the first page, the cursor should go to the first column of the second page.

I am using
.MoveRight unit:=wdCell
.MoveLeft unit:=wdCell

to move the cursor from first column to second column and vice versa. But I am not able to find when the soft page break occurs and in which column I am(either in the first or second) to move the cursor accordingly.

Hope I am clear...if not pls. question me...
0
amiteshsinhaAuthor Commented:
Any answers????
0
AntonioPCommented:
You're using tables?  That changes everything; I thought you just were using column formatting for free text.

I'm afraid I never use Word tables, but hopefully someone better than I can take this question further. Good Luck!
0
amiteshsinhaAuthor Commented:
HI AntonioP

Is thr any way where I can achieve the format I want without using tables??
0
AntonioPCommented:
Well, if I understand the code (which I may not), you're creating a table that consists of 1 row and two columns, going to the left cell, and filling it with text.  And you want for that text to fill the left cell until the end of the page, then move to the right cell and start filling that to the end of the page, then move to the next page.

If so, this is exactly what Word's column formatting is for.  Start with a new document, use the code that GrahamSkan supplied, and then just start blasting the text into the document.  You may need to experiment a bit with the column widths, etc., to give you the formatting you want, but you should be all set.  Also, you may want to format each group with

    Selection.ParagraphFormat.KeepTogether = True

so that you do not have the feature name ending up on one page and the bullets on the next.

If you want to see how the column formatting works before you start re-writing your code, just make a new document,
use Format>Columns to make it two columns, and type in "=rand(20,4)" and hit return.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amiteshsinhaAuthor Commented:
Wow...this is what I was looking for. Thanks a loooot...

0
amiteshsinhaAuthor Commented:
Hi..

In this same issue I have one more clarification.
In a single page how to make one TextColumns count as 1 and another TextColumns count as 2...??
Let me know if I've to post this as a diff. issue.
0
GrahamSkanRetiredCommented:
It would be a good idea to post another question, but I will tell you now that I don't understand what your new requirement.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.