Word Interop AddLine Anchors

I

Igor

I am trying to add a line in a certain cell in a table contained in a footer.
Here is my relevant code:

Word.Range Ft =
wordApp.ActiveDocument.Sections[1].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;

object Anchor = Ft.Tables[1].Cell(3,3).Range;

wordApp.ActiveDocument.Shapes.Addline(50,200,50,200, ref Anchor);

I get this error when compiling: The specified range is not from the correct
document or story.

How do I add the shape to the specified cell in the footer?

Thanks!
 
C

Cindy M.

Hi Igor,
I am trying to add a line in a certain cell in a table contained in a footer.
Here is my relevant code:

Word.Range Ft =
wordApp.ActiveDocument.Sections[1].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;

object Anchor = Ft.Tables[1].Cell(3,3).Range;

wordApp.ActiveDocument.Shapes.Addline(50,200,50,200, ref Anchor);

I get this error when compiling: The specified range is not from the correct
document or story.

How do I add the shape to the specified cell in the footer?

You can try collapsing the Range to its Start point (Range.Collapse
(Word.WdCollapseDirection.wdCollapseStart). The entire range of a cell also includes the cell
structures, which could be causing the problem you're seeing.

However, why try putting a line "in" a cell? Why not just apply a border to that cell?

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