none
Can't sort table containing mapped repeating section CC RRS feed

  • Question

  • I'm not sure if it is a bug or by design, but I notice that Word will not sort a table that contains a mapped repeating section CC.  Attempts using table sort results in the repeating section CC and table content being deleted from the document.  I've managed a crude work around using vba:

    Sub WorkAround()
    Dim oTbl1 As Word.Table, oTbl2 As Word.Table
    Dim oRng As Word.Range
    Dim oCell As Word.Cell
    ActiveDocument.Range.InsertAfter vbCr & vbCr
    
    Set oRng = ActiveDocument.Range
    oRng.Collapse wdCollapseEnd
    Set oTbl1 = ActiveDocument.Tables(ActiveDocument.Tables.Count)
    Set oTbl2 = oRng.Tables.Add(oRng, oTbl1.Rows.Count, oTbl1.Columns.Count)
    For Each oCell In oTbl1.Range.Cells
      oCell.Range.Select
      On Error GoTo Err_Handler
      oTbl2.Cell(oCell.RowIndex, oCell.ColumnIndex).Range = oCell.Range
    Next oCell
    oTbl2.Sort ExcludeHeader:=True, FieldNumber:="Column 2", SortFieldType _
        :=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending, FieldNumber2 _
        :="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:= _
        wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
        wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending
    For Each oCell In oTbl1.Range.Cells
    
      oCell.Range.ContentControls(oCell.Range.ContentControls.Count).Range.Text = oTbl2.Cell(oCell.RowIndex, oCell.ColumnIndex).Range.Text
      On Error GoTo Err_Handler
      oTbl2.Cell(oCell.RowIndex, oCell.ColumnIndex).Range = oCell.Range
    ReEntry:
    Next oCell
    oTbl2.Delete
    Exit Sub
    Err_Handler:
      oTbl2.Cell(oCell.RowIndex, oCell.ColumnIndex).Range.Text = oCell.Range.Text
      Resume ReEntry
    End Sub
    
    Anyone have an idea why the table won't sor or a better way? Thanks.

    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Friday, May 17, 2013 4:50 AM

All replies

  • Hi Greg,

    Thank you for posting in the MSDN Forum.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 20, 2013 12:56 PM
    Moderator
  • I have witnessed the same problem. However, your code did not solve the problem.

    In fact, I could not get it to completely execute without a bunch of run-time errors.
    I could not see how you were effectively handling the bypass of the table headers in your code.


    • Edited by Syswizard Monday, May 20, 2013 6:40 PM
    Monday, May 20, 2013 6:39 PM
  • There is a working example here:  https://dl.dropboxusercontent.com/u/64545773/Test%20Table.docm

    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Monday, May 20, 2013 9:13 PM
  • Hi Greg,

    I took a look at the sample file you listed in the link above.  I was unable to reproduce the problem on my machine and had the following questions.
    1) What is the build number of Word that you are using?
    2) Can you verify whether there are any add-ins running in Word that may be causing the behavior?

    Best Regards, 
    Travis O.
    Microsoft Online Community Support

    Wednesday, May 22, 2013 3:59 PM
  • Travis,

    I'm not imagining this because I was only made aware of it by another user who contacted me for a work around.

    I'm not sure how to tell the build number however removing all com and template add-ins has no effect.

    I've posted the original table sent to me by the create.  If I put my cusor in the RSCC and attempt to sort, all rows accept the heading row disappear.

    Thanks.


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Thursday, May 23, 2013 1:50 AM
  • Hi Greg,

    You can get the version number of word by taking the following steps:

    - Navigate to winword.exe in Windows Explorer (usually found in a path similar to the following:

    C:\Program Files (x86)\Microsoft Office\Office14

    C:\Program Files (x86)\Microsoft Office\Office15

    - Right click on winword.exe and choose properties.

    - Click the details tab and we can get the version number.

    Without being able to reproduce it, this may be beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs: http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Best Regards, 

    Travis O.

    Microsoft Online Community Support

    Thursday, May 23, 2013 9:01 PM
  • Travis,

    The File version is: 15.04420.1017


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Thursday, May 23, 2013 9:12 PM
  • Hi Greg,

    I have the same version of Word and I am unable to reproduce the issue.  Seeign as we are unable to reproduce it, I urge you to open a support case with us. Visit this link to see the various support options that are available to better meet your needs: http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Best Regards, 

    Travis O.

    Microsoft Online Community Support

    Wednesday, May 29, 2013 7:28 PM