Add to Word document with bullet-end formatting

I am working on a process that reads a Word document and adds some images to the end. The problem I'm running into is that the document ends up with a letter list and the images I add become part of that list. I can't seem to find a way to end this list before adding images.

Microsoft.Office.Interop.Word.Application winword =
    new Microsoft.Office.Interop.Word.Application();
winword.Visible = false;
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document document = winword.Documents.Open(documentName);

object lastLine = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
object lastDirection = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToLast;
document.Sections.Add(missing);
document.Sections[document.Sections.Count]
    .Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
document.Sections[document.Sections.Count]
    .Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "";

winword.Selection.GoTo(ref lastLine, ref lastDirection, ref missing, ref missing);
winword.Selection.EndKey(WdUnits.wdStory, missing);

foreach(string image in images)
{
    document.Application.Selection.InlineShapes.AddPicture(image);
}

document.SaveAs2("finished.doc",
                  Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument97);
document.Close();
winword.Quit();

      

+3


source to share





All Articles