How to create powerpoint slides using vs 2008(asp.net 3.5, C#)

how to create powerpoint slides

Page 1 of 1

2 Replies - 7676 Views - Last Post: 19 April 2009 - 11:34 PM Rate Topic: -----

#1 dulani_ua  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 19-April 09

How to create powerpoint slides using vs 2008(asp.net 3.5, C#)

Posted 19 April 2009 - 09:17 PM

hi all,

How to create powerpoint slides using visual studio 2008 (c#)?

I want to create power point using DB values.

1.create power point slides using DB values - in button click
2. open file

Please advice... Thanks in advance...
Is This A Good Question/Topic? 0
  • +

Replies To: How to create powerpoint slides using vs 2008(asp.net 3.5, C#)

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to create powerpoint slides using vs 2008(asp.net 3.5, C#)

Posted 19 April 2009 - 10:13 PM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 dulani_ua  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 19-April 09

Re: How to create powerpoint slides using vs 2008(asp.net 3.5, C#)

Posted 19 April 2009 - 11:34 PM

View PostPsychoCoder, on 19 Apr, 2009 - 09:13 PM, said:

[rules][/rules]

this is my code. Now I want to modify this to add multiple slides according to size of data. How to do that?
 

protected void Create_Click(object sender, EventArgs e)
	{
		bool filled = true;
		if (filled == true)
		{
			CPPTGeneration ppt = new CPPTGeneration();

			//PPTAuto ppt = new PPTAuto();
			StringCollection array = new StringCollection();

			array.Insert(0, "Dulani");
			array.Insert(1, "28");
			array.Insert(2, "Developer");
			array.Insert(3, "DEV");
			array.Insert(4, "Colombo");
			array.Insert(5, "Dulani@yahoo.com");

			ppt.CreateFile(array);

		}
	}
	

	public class CPPTGeneration
	{
		PowerPoint.Application objApp;
		PowerPoint.Presentations objPresSet;
		PowerPoint._Presentation objPres;
		PowerPoint.Slides objSlides;
		PowerPoint._Slide objSlide;
		PowerPoint.TextRange objTextRng;
		PowerPoint.TextRange objTextRng1;

		public CPPTGeneration()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		


		public void CreateFile(System.Collections.Specialized.StringCollection array)
		{
			//throw new NotImplementedException();
		
			String strTemplate;
			//strTemplate = "C:\\Program Files\\Microsoft Office\\Templates\\Presentation Designs\\Glass Layers.pot";
			strTemplate = "F:\\PowerpointPresentation\\Templates\\Glass Layers.pot";

			//Create a new presentation based on a template.
			objApp = new PowerPoint.Application();
			objApp.Visible = MsoTriState.msoTrue;
			objPresSet = objApp.Presentations;
			objPres = objPresSet.Open(strTemplate,
				MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);

			objSlides = objPres.Slides;

			// Adding a slide 
			objSlide = objSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);


			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 100, 500, 80);
			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 150, 500, 80);
			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 200, 500, 80);
			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 250, 500, 80);
			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 300, 500, 80);
			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 350, 500, 80);
			objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 400, 500, 80);

			objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
			objTextRng.Text = "These are my details";
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;

			objTextRng = objSlide.Shapes[2].TextFrame.TextRange;
			objTextRng.Text = array[0];
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;

			objTextRng = objSlide.Shapes[3].TextFrame.TextRange;
			objTextRng.Text = array[1];
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;

			objTextRng = objSlide.Shapes[4].TextFrame.TextRange;
			objTextRng.Text = array[2];
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;

			objTextRng = objSlide.Shapes[5].TextFrame.TextRange;
			objTextRng.Text = array[3];
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;

			objTextRng = objSlide.Shapes[6].TextFrame.TextRange;
			objTextRng.Text = array[4];
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;

			objTextRng = objSlide.Shapes[7].TextFrame.TextRange;
			objTextRng.Text = array[5];
			objTextRng.Font.Name = "Arial";
			objTextRng.Font.Size = 20;



			//			// Place two shapes on the slide. 
			//			PowerPoint.Shape objSquareShape = objSlide.Shapes.AddShape
			//												(MsoAutoShapeType.msoShapeRectangle, 
			//													0, 0, 100, 100);
			//			PowerPoint.Shape objTriangleShape =  objSlide.Shapes.AddShape
			//												(MsoAutoShapeType.msoShapeRightTriangle, 
			//														0, 150, 100, 100);
			//
			//
			//			PowerPoint.TextFrame = objSlide.Shapes.AddShape(
			//									(MsoAutoShapeType..msoShapeRectangle, 
			//										0, 0, 100, 100);

			//			objTextRng1 = objSlide.Shapes[2].TextFrame.TextRange;
			//			objTextRng1.Text = "My Sample Presentation";
			//			objTextRng1.Font.Name = "Arial";
			//			objTextRng1.Font.Size = 20;


			//objPres.SaveAs("d:\\Vijay\\Powerpoint\\Sample2.ppt", PpSaveAsFileType.ppSaveAsPresentation, Microsoft.Office.Core.MsoTriState.msoFalse);
			objPres.SaveAs(strTemplate, PowerPoint.PpSaveAsFileType.ppSaveAsPresentation , Microsoft.Office.Core.MsoTriState.msoFalse);
			

		}

	}



Was This Post Helpful? 1

Page 1 of 1