How to change the page shapes.addcurve is drawing on in Word

PAE 1 Reputation point
2021-02-04T14:39:02.88+00:00

Hi, I am annotating words in MSWord with small arcs placed below the words. The user selects some text and pushes on a button to trigger the drawing.
I've figured out how to locate the endpoints of every small curve and am using following call to draw the appropriate arc:

                        float[,] thePoints0 = new float[4, 2]
                        {
                            { x0, y0 },
                            { x0 + (0.4f * w), y0 + h },
                            { x0+(0.6f * w), y0 + h },
                            { x1, y1 },
                        };

                        Shape s = 
                            ColorizationMSW.thisAddIn.Application.ActiveDocument.Shapes.AddCurve(
                            thePoints0, toR);

It works fine as long as the selection does not span accross pages. According to what I can observe, I suppose that my AddCurve call is positioned on some kind of canvas that matches the active page. I cannot draw outside of this canvas. The active page is defined by the beginning of the selection and although the selection covers multiple pages, the canvas does not.

So it looks like I would need to put the active page explicitly to the page I would like to draw on. The only idea that comes to my mind is to create a new selection that would be on the second page. But I don't like the approach, since it has an impact on the user experience (At the end of the process, the selection has changed, or it may flash...). I didn't try this approach yet.

I wonder whether there is an other way to solve my problem.

Thanks in advance

Note: I'm doing this with c# and vsto

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,533 questions
0 comments No comments
{count} votes