jeudi 30 mars 2017

Using Office Add-In I want to place shape on active slide of power point

I am working on one project where User is provided with different Powerpoint templates and based on user selection - shapes will be added to powerpoint slide. This I could achieve quickly and with no issues in VSTO Add-Ins. But I want to place this add-in for sale on Office Store - I need to support Office 2013 and Office 2016. So I had to move from VSTO Add-In to Web Add-In.

Now I need help in converting below code of CSTO Add-In to Web Add-In.

    private void addShapeToSlide(Microsoft.Office.Interop.PowerPoint.Shape newshape, Microsoft.Office.Interop.PowerPoint.Shape shape)
    {
        //newshape.BackgroundStyle = shape.BackgroundStyle;

        newshape.Fill.ForeColor = shape.Fill.ForeColor;
        newshape.Fill.BackColor = shape.Fill.BackColor;

        if (shape.Fill.GradientStyle != MsoGradientStyle.msoGradientMixed)
        {
            newshape.Fill.TwoColorGradient(shape.Fill.GradientStyle, shape.Fill.GradientVariant);

            newshape.Fill.Background();
        }

        newshape.Fill.Transparency = shape.Fill.Transparency;
        newshape.Glow.Color.RGB = shape.Glow.Color.RGB;

        newshape.Name = shape.Name;

        newshape.AnimationSettings.AnimateBackground = shape.AnimationSettings.AnimateBackground;


        newshape.Shadow.Blur = shape.Shadow.Blur;
        newshape.Shadow.OffsetX = shape.Shadow.OffsetX;
        newshape.Shadow.OffsetY = shape.Shadow.OffsetY;
        newshape.Shadow.RotateWithShape = shape.Shadow.RotateWithShape;
        newshape.Shadow.Size = shape.Shadow.Size;
        if (shape.Shadow.Style != MsoShadowStyle.msoShadowStyleMixed)
        {
            newshape.Shadow.ForeColor = shape.Shadow.ForeColor;
            newshape.Shadow.Style = shape.Shadow.Style;
            newshape.Shadow.Transparency = shape.Shadow.Transparency;
        }

        if (shape.Type != MsoShapeType.msoPicture)
        {
            newshape.TextEffect.FontName = shape.TextEffect.FontName;
            newshape.TextEffect.FontSize = shape.TextEffect.FontSize;
            newshape.TextEffect.FontBold = shape.TextEffect.FontBold;
            newshape.TextEffect.FontItalic = shape.TextEffect.FontItalic;
            if (shape.Type != MsoShapeType.msoGroup)
            {
                newshape.TextFrame.TextRange.Font.Color.RGB = shape.TextFrame.TextRange.Font.Color.RGB;
                newshape.TextFrame.TextRange.Text = shape.TextFrame.TextRange.Text;
            }
        }
        else
        {

            //Image a = shape.CanvasItems.Background
            //newshape.CanvasItems.AddPicture()
        }
        newshape.Visible = shape.Visible;
    }

I won't mind even if I get some pointers. I could explore and findout that I have to use "Office.context.document.setSelectedDataAsync" method for placing images but I am not getting anything for placing different shapes.

You help will be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire