0

I'm having trouble figuring out how to work with word ranges. I have picture files that I am adding to a word file, but I can't figure out how to add text and tables in between the pictures. The structure I want is this: Text, table, picture. Then repeat.

However, when I add text or tables, they all area added after the four pictures, which stay at the top of the file. I've been reading and I've figured out I need to use ranges to specify where you want to place the tables/text, but all the resources I found only show how to add at the top of the page.

Tables: http://msdn.microsoft.com/en-us/library/w1702h4a.aspx Text: http://msdn.microsoft.com/en-us/library/6b9478cs.aspx

This is how I add pictures:

        Word.Application wdApp = new Word.Application();
        wdApp.Visible = true;

        Document doc = wdApp.Documents.Add();

        foreach (var category in type){
                // add table/text
                doc.Application.Selection.InlineShapes.AddPicture(@path + "\\" + category + "_" + DateTime.Now.ToString(datePatt) + ".jpg");
            }

I expected to be able to add my text/table before the picture, but it seems I have to specify ranges in the file. How can I do this?

Berkay Turancı
  • 3,373
  • 4
  • 32
  • 45
sixshift04
  • 329
  • 4
  • 8
  • 19

1 Answers1

1

This is a possible duplicate of one of your previous questions: How to add items one at a time to to a new line a word document using word interop

See my previous answer to your similar question here: https://stackoverflow.com/a/12751805/700926 - it gives a short explanation of how to accomplish this as well as a complete sample implementation in C#.

Community
  • 1
  • 1
Lasse Christiansen
  • 10,205
  • 7
  • 50
  • 79