none
Having prob with merged cells of a table when deleting occurences of "[]" in table cells RRS feed

  • Question

  • hi, i am using word 2002, visual studio 2010, C#

    i hve a function removeBraces to remove any occurence of "[]" in my table

     

     

     gf[]ejwfhoguigio[]

     []ghjviki[]vgfiufui[]

     

     

     [][]

     []giugfiufi

     

    for the above table it wrks fine

    the code is as follows

     public void RemoveBraces(Table oTbl)
            {
                //oTbl = app.ActiveDocument.Tables[1];//testing for 1st table in doc

                //oTbl.Cell(1, 1).Range.Find.Execute("[]", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, WdFindWrap.wdFindStop, Type.Missing, "", WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                for (int c = 1; c <= oTbl.Columns.Count; c++)
                {
                    for (int r = 1; r <= oTbl.Rows.Count; r++)
                    {
                        oTbl.Cell(r, c).Range.Select();
                        oTbl.Cell(r, c).Range.Find.Execute("[]", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, WdFindWrap.wdFindStop, Type.Missing, "", WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                    }
                }
            }

     

    now the prob am hving is when cells of that table are merged

    you get zis error : The requested member of the collection does not exist.

    Step

    Material

    Qty

    rhjtrjyk

    [ a ]


    []


    rywjky[b ][]

    7553

    mjy[][c ]

    0.5373

    mjmya

    1537L

    jyu76k[ b ]

    6.ufiL

    5ywk

    Mwyk5k

    fyl

    Dichloyjke[ c ]

    31.5ek

    yjkktu

    18uk

    ytjk

    22.5 wu

    w5yjiw5k

    ytj

    6-1w5u

    jyrjk

    tyjr[]

    13.5 yuq4

    yj

    12yuk

    Puryj

    rtjy

    rawhj4tj[][a ]

    10ju

    in z above table i get zat error cauz of the merge cells

    any idea how i can get in each cell to delete the "[]", even the merge cells

    plz help me

    thks in advance

    Mush

    :)

     

     

     

     

    Thursday, December 23, 2010 6:19 AM

Answers

  • Hi Mush

    Why wouldn't you use:

    oTbl.Range.Find.Execute("[]", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, WdFindWrap.wdFindStop, Type.Missing, "", WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by StarMush Thursday, December 23, 2010 10:19 AM
    Thursday, December 23, 2010 9:03 AM
    Moderator

All replies

  • Hi Mush

    Why wouldn't you use:

    oTbl.Range.Find.Execute("[]", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, WdFindWrap.wdFindStop, Type.Missing, "", WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by StarMush Thursday, December 23, 2010 10:19 AM
    Thursday, December 23, 2010 9:03 AM
    Moderator
  • Hi Mush,

    Unless you're posting SMS messages from a mobile phone, how about using fully-formed words for your posts! Your abbreviations do nothing for readability and, if you want help, it pays to make things easy for those who might give it.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, December 23, 2010 9:10 AM
  • hi Cindy, thks dear didnt knw we could use it zat way as well thks load Mush :)
    Thursday, December 23, 2010 10:18 AM
  • sry macropod copied zat table from word doc but it came out zat way :( anywayz Cindy find z soln thks to her n thk u 4 trying to help, really appreciate it Mush :)
    Thursday, December 23, 2010 10:20 AM