Copy formulas in a row of a Word Table via Word Automation

H

Hilmar Demant

Hi,

i want to copy the formulas in a word table and paste them in a new row. The
cursor is in a cell of the table.
ArrayList lFormulas = new ArrayList();
for (int i=1; i< objRange.Application.Selection.Cells.Count+1; i++)
{
Word.Range ltmpRange = objRange.Application.Selection.Cells.Range;
if (ltmpRange.Fields.Count > 0)
{
lFormulas.Add(ltmpRange.Fields[1].Code.Text);
}
else
{
lFormulas.Add("");
}
....

The code obviously seems not to work, cause the selection-object contains
only one column.
How can i retrieve the current row of the table and loop through the
column-cells?

kind regards,

Hilmar
 
C

Cindy M -WordMVP-

Hi Hilmar,
i want to copy the formulas in a word table and paste them in a new row. The
cursor is in a cell of the table.
ArrayList lFormulas = new ArrayList();
for (int i=1; i< objRange.Application.Selection.Cells.Count+1; i++)
{
Word.Range ltmpRange = objRange.Application.Selection.Cells.Range;
if (ltmpRange.Fields.Count > 0)
{
lFormulas.Add(ltmpRange.Fields[1].Code.Text);
}
else
{
lFormulas.Add("");
}
....

The code obviously seems not to work, cause the selection-object contains
only one column.
How can i retrieve the current row of the table and loop through the
column-cells?

I'm going to give you this in VBA-speak because I'm not sure I understand the
programming language you're working in :) But I think you'll get the idea

Dim rng as Word.Range, cel as Word.Cell
Dim sel as Word.Selection

Set sel = appWd.Selection
If sel.Information(wdWithinTable) = False then Exit Sub

Set rng = sel.Cells(1).Range.Rows(1).Range
For each cel in rng.Cells

Next

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top