0

I want to insert a picture to an exact position in my footer of a word document. In this footer I have a table where I want to place the picture. The text is filled in controls. This works fine as it should be. I have not found out how to define the range in order to get an individual position.

//Get storyRanges from document for header and footer properties
    StoryRanges storyRanges = Globals.ThisDocument.StoryRanges;

// Put text in controls
foreach (Range storyRange in storyRanges)
{
    ContentControls storyRangeControls = storyRange.ContentControls;

    string PngFileFullPath = @"C:\\Users\public\bbv_templates\QS.png";

    if (storyRangeControls != null)
    {
        if (storyRangeControls.Count > 0)
        {
            foreach (Microsoft.Office.Interop.Word.ContentControl bbvControls2 in storyRangeControls)
            {
                if (bbvControls2.Title == "Doc_Subject")
                {
                    bbvControls2.Range.Text = textBox27.Text;
                }
                if (bbvControls2.Title == "bbvFooter")
                {
                    if (comboBox9.Text == "Fusszeile D") 
                    {
                        bbvControls2.Range.Text = "bbb";


                        // Add new image

// ??? How can I specify the Position

                        var docRange = aa 
                        
                        InlineShape img = bbvControls2.Range.InlineShapes.AddPicture(PngFileFullPath, false, true, docRange);
                        img.Width = 80;
                        img.Height = 80;

                    }
                    if (comboBox9.Text == "Footer CH") 
                    {
                        bbvControls2.Range.Text = "aaa";
                    }
                }
                if (bbvControls2.Title == "bbvFooter2")
                {
                    if (comboBox9.Text == "Fusszeile D") 
                    {
                        bbvControls2.Range.Text = "www.aaa.eu";
                    }
                    if (comboBox9.Text == "Fusszeile CH") 
                    {
                        bbvControls2.Range.Text = "www.bbb.ch";
                    }
                }
            }
        }
    }
} 

0 Answers0