Esempio n. 1
0
        private void Write(object sender, EventArgs e)
        {
            bool new_presentation = NoPowerPoint();

            try
            { if (new_presentation)
              {
                  if (!CreateNewPresentation())
                  {
                      return;                                                                //If there is no presentation open create one, but return if the user cancels.
                  }
              }
              foreach (var item in presentation.Slides[1].Shapes)
              {
                  var shape = (Ppt.Shape)item;
                  if (shape.HasTextFrame != msoTrue)
                  {
                      continue;
                  }

                  if (shape.Name.Contains("Title"))
                  {
                      shape.TextFrame.TextRange.Text = TitleBox.Text;
                  }

                  else
                  {
                      IDataObject clipped = Clipboard.GetDataObject();
                      BodyTextBox.SelectAll();
                      BodyTextBox.Copy();
                      shape.TextFrame.TextRange.Paste();
                      Clipboard.SetDataObject(clipped, true);
                  }
              }

              if (new_presentation)
              {
                  try { presentation.SaveAs(file_path); }
                  catch (FileNotFoundException)
                  { MessageBox.Show(save_err_msg + file_path + " (invalid name)."); }
              }
              catch (System.Runtime.InteropServices.COMException exc)
              { MessageBox.Show(save_err_msg + file_path + ":\n\n" + exc); } } catch (System.Runtime.InteropServices.COMException exc)