Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Inserting columns in rows with text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
malyjohn@hotmail.com - 04 May 2006 09:53 GMT
Hello!
I have in Word a table with following rows:
...
John
180cm  65kg  20/17 ws
Mike
178cm  75kg  30/15 ns
198753 198765 123 qd
Kevin
no data
Tom
173cm  73kg  40/18 es
...
I would like to insert columns in some of rows to get something like
that

John
180cm  | 65kg    | 20/17 | ws
Mike
178cm  | 75kg    | 30/15 | ns
198753 | 198765 | 123    | qd
Kevin
no data
Tom
173cm  | 73kg    | 40/18 | es
...
My table counts more than thousand rows so this makes way "by hand"
useless.
Is there any way in VBA to check row by row of the table and if row
satisfies some conditions insert colums with given width?
Thank you in advance
                                       John Maly
Cindy M  -WordMVP- - 05 May 2006 14:08 GMT
> I have in Word a table with following rows:
> ....
[quoted text clipped - 25 lines]
> Is there any way in VBA to check row by row of the table and if row
> satisfies some conditions insert colums with given width?

Yes... with reservations. It depends on whether the information in the
rows that need to be changed can be uniquely identified. In the sample
you give us, the rows you want to split have spaces between the "data
elements". Can you rely on the fact that
   - only rows containing spaces should be split
   - that the only spaces in these row are where the splits should be
made?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
malyjohn@hotmail.com - 11 May 2006 06:33 GMT
I don't want to split rows where are names and where are "no data".
And other rows where the splits should be made have more spaces than
one.
Any idea how to make it?
                              John Maly

> Can you rely on the fact that
>     - only rows containing spaces should be split
>     - that the only spaces in these row are where the splits should be
> made?
Cindy M  -WordMVP- - 11 May 2006 15:34 GMT
> I don't want to split rows where are names and where are "no data".
> And other rows where the splits should be made have more spaces than
> one.
> Any idea how to make it?
>                              
Well, the logic to determine what is a name and what is not is not buit
into any programming language. You have to define how to recognize whether
something is a name. If you can't do that, then no, it can't be done. If
you can do that, then...

You have to be sure that data items are clearly identifiable; that the
same character, or sets of characters, ALWAYS can be found between data
items. If you can do that, then it probably can be done.

If either of the above can't be defined, then no, it can't be done. If you
want me to give you sample code, then you MUST clearly define how these
things are recognized. The people in these groups are just like you: we
work for a living, our time is precious, we can't spend a lot of it trying
this/trying that until we figure out what you really mean.

If there's a language barrier (I get the feeling English isn't your first
language?), try stating the case in French or German, or ask in a group
specific for your language.  

> > Can you rely on the fact that
> >     - only rows containing spaces should be split
> >     - that the only spaces in these row are where the splits should be
> > made?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.