PBGuy Ответов: 1

Вставьте смарт статья в МС офис ppt слайд, через C# библиотеки DLL взаимодействия


Спешить,

У меня есть проблемы с вставкой смарт-арта в powerpoint через код c#.
Ошибка отображается, когда я пытаюсь добавить смарт-арт на слайд,

Я пытался

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


Нужно ли ссылаться на дополнительные библиотеки DLL? Я уже включил ядро и powerpoint.
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;


Я также попробовал этот способ: вставил прямоугольник и добавил текст на слайд, как

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.

Спасибо

1 Ответов

Рейтинг:
1

abdul subhan mohammed

Просто измените word на powerpoint, надеюсь, это вам поможет!

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;
}


Перечисление
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,

   }