.net - Inserting new lines between images C# Word -
.net - Inserting new lines between images C# Word -
this question has reply here:
how add together items 1 @ time to new line word document using word interop 1 replyi insert image, new line , image. process has repeated until images inserted. code of inserts images, not blank lines
using system.io; using word = microsoft.office.interop.word; namespace snapper { class worddocumentgenerator { public void createworddocument(string filename) { string originalpath = directory.getcurrentdirectory(); string path = originalpath; path += @"\snapshots"; object omissing = system.reflection.missing.value; //create new word application word._application wordapp = new word.application(); wordapp.visible = false; seek { //create new blank document word._document doc = wordapp.documents.add(ref omissing, ref omissing, ref omissing, ref omissing); string[] images = directory.getfiles(path); //create range object mytrue = true; object myfalse = false; object endofdoc = "\\endofdoc"; object myrange; foreach (var image in images) { myrange = doc.bookmarks.get_item(ref endofdoc).range; //add images document doc.inlineshapes.addpicture(image, ref myfalse, ref mytrue, ref myrange); //add blank line //doc.content.text = "\n"; } path = originalpath; path += @"\documents"; directoryinfo docdir = new directoryinfo(path); if (!docdir.exists) { docdir.create(); } object savepath = path + @"\" + filename + ".doc"; doc.saveas(ref savepath, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing ); doc.save(); } { wordapp.quit(ref omissing, ref omissing, ref omissing); } } } }
i need help in doing it.
thanks all, search showed question has been asked already. reply pretty much solved problem.
how add together items 1 @ time to new line word document using word interop
c# .net ms-word
Comments
Post a Comment