views:

15

answers:

0

Hi all I am working on word automation. i am having a problem.

I want to insert caption at the first row of the table . my table contain 3 rows as header,chart,note, upto this is all well . when i type some text in the header it works fine. but when i am adding a caption at the first row this add caption above the table or below the table. my code function is like this.

  AddCaption(heading, oTable.Rows[1].Range, Word.WdCaptionLabelID.wdCaptionFigure);

function which i am calling

  private void AddCaption(string heading, Word.Range rn, Word.WdCaptionLabelID captionstyle)
        {
            // Application.CaptionLabels.Add("Chart");
            object caption = this.Application.CaptionLabels["Chart"];
            if (captionstyle == Word.WdCaptionLabelID.wdCaptionFigure)
            {
                rn.InsertCaption(ref caption, " " + heading, ref oMissing, Word.WdCaptionPosition.wdCaptionPositionAbove, ref oMissing);
            }
            else
            {
                rn.InsertCaption(captionstyle, " " + heading, ref oMissing, Word.WdCaptionPosition.wdCaptionPositionAbove, ref oMissing);
            }
        }

the above code adds the caption text as i want but not at the position on which i want to add.

is there any way to add the caption at the first row of the table.

Thanks