By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

PowerPoint Table C#

P: 3
Hi Guys,

What i want to do is:

I want to create a Slide programmatically where a Table is on it! Here´s my Code:

Expand|Select|Wrap|Line Numbers
  1. String strTemplate;
  2.             strTemplate = template;
  3.             String tableSlide = @"C:\Temp\TableSlide_" + guid.ToString();
  4.  
  5.             PowerPoint.Application objApp;
  6.             PowerPoint.Presentations objPresSet;
  7.             PowerPoint._Presentation objPres;
  8.             PowerPoint.Slides objSlides;
  9.             PowerPoint._Slide objSlide;
  10.             PowerPoint.TextRange objTextRng;
  11.  
  12.             //Create a new presentation based on a template.
  13.             objApp = new PowerPoint.Application();
  14.             objApp.Visible = MsoTriState.msoTrue;
  15.             objPresSet = objApp.Presentations;
  16.             objPres = objPresSet.Open(strTemplate,
  17.                 MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
  18.             objSlides = objPres.Slides;
  19.  
  20.  
  21.             //Build Slide #1:
  22.             //Add text to the slide, change the font and insert/position a
  23.             //picture on the first slide.
  24.             objSlide = objSlides.Add(1,PowerPoint.PpSlideLayout.ppLayoutTable);
  25.             objSlide.HeadersFooters.Footer.Visible = MsoTriState.msoTrue;
  26.             objSlide.HeadersFooters.Footer.Text = "hallo";
  27.  
  28.  
  29.             objSlide.HeadersFooters.DateAndTime.Visible = MsoTriState.msoTrue;
  30.             objSlide.HeadersFooters.DateAndTime.UseFormat = MsoTriState.msoTrue;
  31.             objSlide.HeadersFooters.DateAndTime.Format = Microsoft.Office.Interop.PowerPoint.PpDateTimeFormat.ppDateTimeddddMMMMddyyyy;
  32.             objSlide.HeadersFooters.SlideNumber.Visible = MsoTriState.msoTrue;
  33.             objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
  34.             objTextRng.Text = title;
  35.  
  36.  
  37.             // insert a PowerPoint table
  38.             // use data from a file
  39.             PowerPoint.Table objTable = null;
  40.  
  41.             objTable= objSlide.Shapes.AddTable(4,4,36,138,648,294).Table;
  42.  
  43.  
  44.             objTable.Cell(1,1).Shape.TextFrame.TextRange.Text = "Stundennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn";
  45.             objTable.Cell(1, 2).Shape.TextFrame.TextRange.Text = "Fach";
  46.             objTable.Cell(1, 3).Shape.TextFrame.TextRange.Text = "Note";
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.             objPres.SaveAs(tableSlide, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoCTrue);
  54.             //Close the presentation without saving changes and quit PowerPoint.
  55.             objPres.Close();
  56.             objApp.Quit();
But if the String in Cell (1,1)for example, is very long then i want that the cell weigth goes bigger automatically! how can i do this?

Sorry for my bad english...:)
Nov 13 '09 #1
Share this Question
Share on Google+
1 Reply


P: 3
No One? Can anybody help me?
Nov 16 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.