Exemple #1
0
        public void InsertImage(string strPicPath, float picWidth, float picHeight)
        {
            string FileName         = strPicPath;
            object LinkToFile       = false;
            object SaveWithDocument = true;
            object Anchor           = OWordApplic.Selection.Range;

            OWordApplic.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor).Select();
            OWordApplic.Selection.InlineShapes[1].Width  = picWidth;  // 图片宽度
            OWordApplic.Selection.InlineShapes[1].Height = picHeight; // 图片高度

            // 将图片设置为四面环绕型
            Word.Shape s = OWordApplic.Selection.InlineShapes[1].ConvertToShape();
            s.WrapFormat.Type = Word.WdWrapType.wdWrapSquare;
        }
Exemple #2
0
        public void InsertLine(float left, float top, float width, float weight, int r, int g, int b)
        {
            //SetFontColor("red");
            //SetAlignment("Center");
            object Anchor = OWordApplic.Selection.Range;
            //int pLeft = 0, pTop = 0, pWidth = 0, pHeight = 0;
            //oWordApplic.ActiveWindow.GetPoint(out pLeft, out pTop, out pWidth, out pHeight,missing);
            //MessageBox.Show(pLeft + "," + pTop + "," + pWidth + "," + pHeight);
            object rep = false;

            //left += oWordApplic.ActiveDocument.PageSetup.LeftMargin;
            left  = OWordApplic.CentimetersToPoints(left);
            top   = OWordApplic.CentimetersToPoints(top);
            width = OWordApplic.CentimetersToPoints(width);
            Word.Shape s = OWordApplic.ActiveDocument.Shapes.AddLine(0, top, width, top, ref Anchor);
            s.Line.ForeColor.RGB = RGB(r, g, b);
            s.Line.Visible       = Microsoft.Office.Core.MsoTriState.msoTrue;
            s.Line.Style         = Microsoft.Office.Core.MsoLineStyle.msoLineSingle;
            s.Line.Weight        = weight;
        }