Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the blade domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u112623068/domains/mzekiosmancik.com/public_html/wp-includes/functions.php on line 6114
C# ile Powerpoint Sunumu Hazırlamak | MeZO Blog
  • By mezo
  • 27/09/2014

C# ile Powerpoint Sunumu Hazırlamak

C# ile Powerpoint Sunumu Hazırlamak

C# ile Powerpoint Sunumu Hazırlamak 554 382 mezo

Merhaba arkadaşlar
Uzun süreden beri bir makale yazmaya vakit bulamıyorum ama yavaş yavaş geri dönüyorum. Bu yazıda sizlere zevkli küçük bir örnek göstermek istiyorum. 😀 C# üzerinden program yardımı ile PowerPoint sunumu hazırlamanın nasıl olduğu ile ilgili başlangıçta çok işinize yarayacak bir kod parçası
Bunun için öncelikle bir windows Forms projesi açalım ve 1 tane Buton ekleyelim 🙂 Projemiz içersine Referans olarak 2 önemli kütüphane eklememiz gerekiyor. Sağa tıklayıp “Add Reference” dedikten sonra “COM” sekmesi içersinde bulunan microsoft graph 15.0 object library ve microsoft PowerPoint 15.0 object library kütüphanelerini seçip ekleyelim.
Artık gerisi çok kolay 🙂 işte bundan sonra işi yapacak olan kod parçası

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;

namespace testToCreatePttFileFromImages
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string pictureFileName = “C:\\picToVideo\\2.jpg”;

Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

Microsoft.Office.Interop.PowerPoint.Slides slides;
Microsoft.Office.Interop.PowerPoint._Slide slide;
Microsoft.Office.Interop.PowerPoint.TextRange objText;

// Create the Presentation File
Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoTrue);

Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];

// Create new Slide
slides = pptPresentation.Slides;
slide = slides.AddSlide(1, customLayout);

// Add title
objText = slide.Shapes[1].TextFrame.TextRange;
objText.Text = “The Header Of The Presentation”;
objText.Font.Name = “Arial”;
objText.Font.Size = 32;

//objText = slide.Shapes[2].TextFrame.TextRange;
//objText.Text = “this text come after the heading with bullet”;

Microsoft.Office.Interop.PowerPoint.Shape shape = slide.Shapes[2];
slide.Shapes.AddPicture(pictureFileName, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, shape.Left, shape.Top, shape.Width, shape.Height);

//slide.NotesPage.Shapes[2].TextFrame.TextRange.Text = “the text is for the notes to specific page”;

pptPresentation.SaveAs(@”c:\picToVideo\fppt.pptx”, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
pptPresentation.Close();
pptApplication.Quit();

}
}
}

1 comment
  • Yekta Duran 19/07/2017 at 4:47 AM

    hocam yine imdadimiza yetistin, tesekkurler, su anda Istanbulda turkcell deyim 🙂

Comments are closed.

    Join our Newsletter

    We'll send you newsletters with news, tips & tricks. No spams here.