word二次开发之 插入图片、插入文件、页码设置
Word.Range range111;
//页边距设置
range111.PageSetup.TopMargin = wdApp.CentimetersToPoints(float.Parse("0"));//上页边距
range111.PageSetup.BottomMargin = wdApp.CentimetersToPoints(float.Parse("0"));//下页边距
range111.PageSetup.LeftMargin = wdApp.CentimetersToPoints(float.Parse("0"));//左页边距
range111.PageSetup.RightMargin = wdApp.CentimetersToPoints(float.Parse("0"));//右页边距
//插入图片
object linkToFile = false;
object saveWithDocument = true;
object rangeInsert;
// imexWord.GoToUpCell();
rangeInsert = range111;
Word.InlineShape shape = wdDoc.InlineShapes.AddPicture(fullName, ref linkToFile, ref saveWithDocument, ref rangeInsert);
//设置图片格式
shape.Width = 600f;
shape.Height = 825f;
Word.Shape pic = shape.ConvertToShape();
pic.WrapFormat.Type = Word.WdWrapType.wdWrapFront;//文字上方
//插入文件,fullName为文档完整路径
object objFalse = false;
object miss = System.Reflection.Missing.Value;
object confirmConversion = false;
object link = false;
object attachment = false;
wdApp.Selection.InsertFile(fullName, ref miss, ref confirmConversion, ref link, ref attachment);