在ms Office PPT幻灯片中插入智能艺术,通过c#interop dlls [英] Insert Smart Art in ms Office PPT slide, through c# interop dlls

查看:140
本文介绍了在ms Office PPT幻灯片中插入智能艺术,通过c#interop dlls的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我无法通过c#代码在powerpoint中插入SMART ART。

当我尝试将智能艺术添加到幻灯片时显示错误,



我试过



Hie,

I have trouble inserting SMART ART in powerpoint through c# code.
Error is shown, when I try to add smart art to the slide,

I tried

PowerPoint.Shape shape = objSlide.Shapes.AddSmartArt(objSlide.Application.SmartArtLayouts[3], 10, 125);





我需要参考额外的dll吗?我已经包含了core和powerpoint。



Do I need to reference additional dlls? I already included core and powerpoint.

using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;





我也尝试过这种方式:插入一个矩形并在幻灯片中添加文字,如





I also tried this way : Inserted a rectangle and added text to the slide like

objSlide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 150, 150, 500, 350);
                    objSlide.Shapes[1].TextFrame.TextRange.Text = "This is Step 1";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;

                    objSlide.Shapes[1].TextFrame.TextRange.Text += "This is Step 2";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;
                    objSlide.Shapes[1].TextFrame.TextRange.Text += "This is Step 3";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;
                    objSlide.Shapes[1].TextFrame.TextRange.Text += "This is Step 4";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;
                    objSlide.Shapes[1].TextFrame.TextRange.Text += "This is Step 5";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;

                    objSlide.Shapes[1].TextFrame.TextRange.Text += "This is Step 6";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;
                    objSlide.Shapes[1].TextFrame.TextRange.Text += "This is Step 7";
                    objSlide.Shapes[1].TextFrame.TextRange.Text += Environment.NewLine;





是否可以将此形状与文本转换为智能艺术..?Intellisense未显示为形状对象,方法转换为智能艺术,



提供建议,以编程方式将智能艺术添加到powerpoint幻灯片。



谢谢



is it possible to convert this shape with text into smart art..?Intellisense is not shown for shape object with method convert to smart art,

Provide suggestions , to add smart art programatically to powerpoint slide.

Thanks

推荐答案

只需将字词更改为powerpoint,希望这会对您有所帮助!

Just change word to powerpoint, hope this will help you!
public static bool InsertSmartArtShape(IQuestion question, string filename, SmartArtShapes _smartArtShape)
{
    WordInterop.Application wordApplication = GetOrCreateWordApplication(question.ObjectStore);

    try
    {
        //Avoid screen flickering or unwanted alerts while initializing
        wordApplication.ScreenUpdating = false;
        WordInterop.WdAlertLevel displayAlertLevel = wordApplication.DisplayAlerts;
        wordApplication.DisplayAlerts = WordInterop.WdAlertLevel.wdAlertsNone;

        WordInterop.Document wordDocument = wordApplication.Documents.Open(filename);

        wordDocument.Shapes.AddSmartArt(wordApplication.SmartArtLayouts[(int)_smartArtShape], 350, 370, 100, 100);

        wordDocument.Save();

        object missing = Type.Missing;
        object save_changes = false;
        wordDocument.Close(ref save_changes, ref missing, ref missing);
        return true;
    }
    catch (Exception)
    {
        Cleanup(question.ObjectStore, true);
    }
    return false;
}





Enum



Enum

public enum SmartArtShapes
   {
       BasicBlockList = 1,
       AlternatingHexagons = 2,
       PictureCaptionList = 3,
       LinedList = 4,
       VerticalBulletList = 5,
       VerticalBoxList = 6,
       VerticalBracketList = 7,
       VaryingWidthList = 8,
       TabList = 9,
       HorizontalBulletList = 10,
       SquareAccentList = 11,
       PictureAccentList = 12,
       BendingPictureAccentList = 13,
       StackedList = 14,
       IncreasingCircleProcess = 15,
       PieProcess = 16,
       DetailedProcess = 17,
       GroupedList = 18,
       HorizontalPictureList = 19,
       ContinuousPictureList = 20,
       PictureStrips = 21,
       VerticalPictureList = 22,
       AlternatingPictureBlocks = 23,
       VerticalPictureAccentList = 24,
       TitledPictureAccentList = 25,
       VerticalBlockList = 26,
       VerticalChevronList = 27,
       VerticalAccentList = 28,
       VerticalArrowList = 29,
       TrapezoidList = 30,
       DescendingBlockList = 31,
       TableList = 32,
       SegmentedProcess = 33,
       VerticalCurvedList = 34,
       PyramidList = 35,
       TargetList = 36,
       HierarchyList = 37,
       VerticalCircleList = 38,
       TableHierarchy = 39,
       ArchitectureLayout = 40,
       BasicProcess = 41,
       StepUpProcess = 42,
       StepDownProcess = 43,
       AccentProcess = 44,
       PictureAccentProcess = 45,
       AlternatingFlow = 46,
       ContinuousBlockProcess = 47,
       IncreasingArrowsProcess = 48,
       InterconnectedBlockProcess = 49,
       ContinuousArrowProcess = 50,
       ConvergingText = 51,
       ProcessArrows = 52,
       CircleAccentTimeline = 53,
       BasicTimeline = 54,
       CircleProcess = 55,
       BasicChevronProcess = 56,
       ChevronAccentProcess = 57,
       ClosedChevronProcess = 58,
       ChevronList = 59,
       SubStepProcess = 60,
       PhasedProcess = 61,
       RandomtoResultProcess = 62,
       VerticalProcess = 63,
       StaggeredProcess = 64,
       ProcessList = 65,
       CircleArrowProcess = 66,
       BasicBendingProcess = 67,
       RepeatingBendingProcess = 68,
       VerticalBendingProcess = 69,
       AscendingPictureAccentProcess = 70,
       UpwardArrow = 71,
       DescendingProcess = 72,
       CircularBendingProcess = 73,
       Equation = 74,
       VerticalEquation = 75,
       Funnel = 76,
       Gear = 77,
       ArrowRibbon = 78,
       OpposingArrows = 79,
       ConvergingArrows = 80,
       DivergingArrows = 81,
       BasicCycle = 82,
       TextCycle = 83,
       BlockCycle = 84,
       NondirectionalCycle = 85,
       ContinuousCycle = 86,
       MultidirectionalCycle = 87,
       SegmentedCycle = 88,
       BasicPie = 89,
       HexagonRadial = 90,
       RadialCycle = 91,
       BasicRadial = 92,
       DivergingRadial = 93,
       RadialVenn = 94,
       CycleMatrix = 95,
       RadialCluster = 96,
       OrganizationChart = 97,
       PictureOrganizationChart = 98,
       NameandTitleOrganizationChart = 99,
       HalfCircleOrganizationChart = 100,
       CirclePictureHierarchy = 101,
       Hierarchy = 102,
       LabeledHierarchy = 103,
       HorizontalOrganizationChart = 104,
       HorizontalMultiLevelHierarchy = 105,
       HorizontalHierarchy = 106,
       HorizontalLabeledHierarchy = 107,
       Balance = 108,
       CircleRelationship = 109,
       HexagonCluster = 110,
       OpposingIdeas = 111,
       PlusandMinus = 112,
       ReverseList = 113,
       CounterbalanceArrows = 114,
       SegmentedPyramid = 115,
       NestedTarget = 116,
       ConvergingRadial = 117,
       RadialList = 118,
       TabbedArc = 119,
       BasicTarget = 120,
       BasicVenn = 121,
       LinearVenn = 122,
       StackedVenn = 123,
       InterconnectedRings = 124,
       BasicMatrix = 125,
       TitledMatrix = 126,
       GridMatrix = 127,
       BasicPyramid = 128,
       InvertedPyramid = 129,
       AccentedPicture = 130,
       CircularPictureCallout = 131,
       RadialPictureList = 132,
       SnapshotPictureList = 133,
       SpiralPicture = 134,
       CaptionedPictures = 135,
       BendingPictureCaption = 136,
       PictureFrame = 137,
       BendingPictureSemiTransparentText = 138,
       BendingPictureBlocks = 139,
       BendingPictureCaptionList = 140,
       TitledPictureBlocks = 141,
       PictureGrid = 142,
       PictureAccentBlocks = 143,
       ThemePictureAccent = 144,
       ThemePictureGrid = 145,
       ThemePictureAlternatingAccent = 146,
       AlternatingPictureCircles = 147,
       TitlePictureLineup = 148,
       PictureLineup = 149,
       FramedTextPicture = 150,
       BubblePictureList = 151,

   }

这篇关于在ms Office PPT幻灯片中插入智能艺术,通过c#interop dlls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆