Generate things from scratch RRS feed

  • Question

  • Hello all! im new to this and i would like a simple Hello World example...

    like... to create the most basic presentation u do like this, and to add a new slide u do this, and to add a text box u do this, and to change the text of the textbox to Hello World u do this... i dont know if im asking too much... google does is not helping much now... and the MS samples are way to complex... wich i think is very odd, because u usually find alot more hello world and simple daily tasks then the "Merge Presentations"...

    tks anyway!

    Wednesday, December 28, 2011 10:35 PM


  • Hi LeonardoIndex,


    Thanks for post in the MSDN Forum.


    This is a sample. I hope it can help you.

    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 DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;
    using DocumentFormat.OpenXml;
    namespace WindowsFormsApplication10
        public partial class Form1 : Form
            public Form1()
            private void button1_Click(object sender, EventArgs e)
                SaveFileDialog objSaveFileDialog = new SaveFileDialog();
                objSaveFileDialog.Filter = "Word Document (*.docx)|*docx";
                string strPath = objSaveFileDialog.FileName;
                using (WordprocessingDocument objWordDocument = 
                    MainDocumentPart objMainDocumentPart = 
                    Document objDocument = new Document();
                    Body objBody = new Body();
                    Paragraph objParagraph = new Paragraph();
                    Run objRun = new Run();
                    Text objText = new Text();
                    objText.Text = "Hello World!";
                    objMainDocumentPart.Document = objDocument;
                    DocumentSettingsPart objDocumentSettingPart = 
                    objDocumentSettingPart.Settings = new Settings();
                    Compatibility objCompatibility = new Compatibility();
                    CompatibilitySetting objCompatibilitySetting = 
                        new CompatibilitySetting() 
                            Name = CompatSettingNameValues.CompatibilityMode, 
                            Uri = "", 
                            Val = "14" 


    Have a good day,



    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 30, 2011 7:47 AM