Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combining Tables (Word XP)

    Hi. Does anyone know why Word sometimes combines tables and sometimes keeps them as separate tables? Here's the situation:

    I have Table 1 in Document 1, and Table 2 in Document 2. I copy some rows from table 2 and paste them at the end of Table 1. Sometimes, Word "combines" the rows from Table 2 so that Document 1 now just has a bigger table, while sometimes the pasted rows are regarded as a new, second table in Document 1. If I try to duplicate it from scratch (with "bogus" files) I always seem to end up with just one table, even if the formats of the two tables were somewhat different. But when I use "real" documents, the pasted rows always come in as a new table.

    Any ideas?
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Combining Tables (Word XP)

    My guess is that it depends on what exactly you are copying. If your copied text includes the end of row markers (to the right of each row) or the end of table marker (to the right of the last row) then you will likely be inserting separate rows or an embedded table.

    I know that sometimes I have to add a new row at the bottom of a table I want to copy so I can be sure to exclude the end of table marker that causes problems when the paste is inside an existing table.

    There was a recent thread (in the last week) on pasting rows where the end of row markers were involved.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combining Tables (Word XP)

    As much as I was hoping you'd hit the nail on the head, the rows I'm copying are from the middle of a table, so there are no end of table markers. I'm finding all manner of funky behavior when I manipulate the table(s) through code, so I wouldn't be surprised if the source table were somehow compromised (although I created it myself from someone else's template.)

    For example, I noticed that, if I'm working with the range of rows that I just pasted (which I call rDestination), I can't set the indent of the entire range all at once; I need to loop, which is contrary to all documentation I can find.

    In other words, the following command only worked on the first row of the pasted range:
    rDestination.Rows.LeftIndent = InchesToPoints(0)

    To fix all rows, I had to use
    With rDestination
    For Each rRow In .Rows
    rRow.LeftIndent = InchesToPoints(0)
    Next
    End With

    I understand working with tables is difficult for Word, but it's even more difficult for a programmer!
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  4. #4
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combining Tables (Word XP) Giving up?

    Some days you get the bear; some days you have to program Word tables! NOW I notice that some commands only seem to work in "real time."

    See this code?
    With myRange.Tables(1)
    .LeftPadding = InchesToPoints(0.08)
    .RightPadding = InchesToPoints(0.08)
    .Spacing = 0
    .AllowPageBreaks = True
    .AllowAutoFit = False
    .PreferredWidthType = wdPreferredWidthPoints
    .PreferredWidth = InchesToPoints(6.15)
    End With
    (The odd measurements are simply because I need to make it match up with the table into which it's being pasted.)

    Seems to make sense, no? I just want to set the rows of the table to a certain width. Works fine when I step through it. But no... Word isn't done with me yet! The last line (setting the width of the rows in the table to 6.15" actually "hesitates" when I step through it; I "F8" past it and it takes a second or two until I see the rows adjust to the new width. But apparently, executing the command(s) within a module doesn't "give the table enough time." It flies past it and the rows stay the exact same width as they were before the command was issued.

    Any ideas? This table stuff is driving me insane!
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Combining Tables (Word XP)

    I think this might have something to do with whether the tables are floating or not. Try looking at the Properties of both tables, see if Text Wrapping is set to the same value.

    StuartR

  6. #6
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combining Tables (Word XP)

    Nope, they're the same. The tables are different widths, and some rows have different indents, but that's what I'm trying to fix... bummer for me.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Combining Tables (Word XP) Giving up?

    You might try a Lounge search for PreferredWidth. I seem to remember some problems with that property...

  8. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Combining Tables (Word XP)

    <P ID="edit" class=small>(Edited by macropod on 01-Dec-05 09:56. Code Revision - the update works more reliably)</P>Hi Mesaka,

    You might find the approach I've taken in the attached code useful. It requires all the source cells to be selected, and for anywhere on the table row below which the data are to be pasted into the target document to be selected.

    Instead of copying & pasting rows from one document to the other, my code works out how many rows the target table needs to have added to it, and inserts that many empty rows beneath the currently-selected row. It then copies & pastes only the selected cells from the source table. The latter gives you the flexibility to select and paste cells in the middle of the table - the columns either side of those selected in the source document are ignored and the corresponding cells in the target document are left empty.

    By adding rows to the existing table, and only pasting individual cell contents, column alignment issues are avoided.

    Cheers
    Attached Files Attached Files
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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