Finding the number of columns in TextColumns

R

Richard

I need to find out how many columns are in a document.
I am using the TextColumns object and checking its count property, but if
the user changes the orientation of the page or the number of columns this
property becomes 9999999 even if they have only created three columns. Even
if I loop through all the columns in the collection I still cant find the
real number of columns in the document.

Is this some sort of bug in word or do I need to do something before I read
this property?
 
H

Helmut Weber

Hi Richard,
most often 9999999 shows, that there
would me more than one answer to a question,
that is to say, the result would be ambiguous.
 
S

Stefan Blom

If the document contains multiple sections, you have to investigate
the number of columns for each individual section.

The following would produce the correct result for each section in the
active document:

For Each s In ActiveDocument.Sections

Debug.Print s.PageSetup.TextColumns.Count

Next s

Or in order to get the number of columns of the first section
contained in the current selection, you could use:

Debug.Print Selection.Sections(1).PageSetup.TextColumns.Count
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top