internal static void InsertFooter(Microsoft.Office.Interop.PowerPoint.DocumentWindow window) { // see if footer exists PowerPoint.Shape footer = null; bool footerExists; try { footer = window.View.Slide.Shapes["August Footer"]; footerExists = true; // if user wants to format exising footer, continue, otherwise return DialogResult result = MessageBox.Show( "Footer already created.\nDo you want to format the existing footer instead?", "", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } catch (Exception) { footerExists = false; } // if no footer, create a new footer if (!footerExists) { // add the text box // from http://msdn.microsoft.com/en-us/library/ff743980(v=office.14).aspx // AddTextbox(Orientation, Left, Top, Width, Height) footer = window.View.Slide.Shapes. AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 150, 100, 400, 100); // set text and name footer.TextFrame2.TextRange.Text = "[footer text]"; footer.Name = "August Footer"; } // if we came this far, format the footer // align bottom and left footer.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorBottom; footer.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft; // autosize and wordwrap footer.TextFrame2.AutoSize = Microsoft.Office.Core.MsoAutoSize.msoAutoSizeShapeToFitText; footer.TextFrame2.WordWrap = Microsoft.Office.Core.MsoTriState.msoTrue; // font size (should be 8pt) and italics etc footer.TextFrame2.TextRange.Font.Size = 8F; footer.TextFrame2.TextRange.Font.Italic = Microsoft.Office.Core.MsoTriState.msoTrue; footer.TextFrame2.TextRange.Font.Bold = Office.MsoTriState.msoFalse; // margins footer.TextFrame2.MarginLeft = 0.1f * Constants.PointsPerCm; footer.TextFrame2.MarginRight = 0.1f * Constants.PointsPerCm; footer.TextFrame2.MarginTop = 0f; footer.TextFrame2.MarginBottom = 0f; // no fill / line footer.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoFalse; footer.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse; // set position and width footer.Left = 1.1f * Constants.PointsPerCm; footer.Top = 17.92f * Constants.PointsPerCm - footer.Height; // align bottom to 17.92, i.e. top at that pos minus height footer.Width = 23.2f * Constants.PointsPerCm; }
/// <summary> /// Fired when active presentation gets focus /// </summary> /// <param name="Pres"></param> /// <param name="Wn"></param> void Application_WindowActivate(Microsoft.Office.Interop.PowerPoint.Presentation Pres, Microsoft.Office.Interop.PowerPoint.DocumentWindow Wn) { System.Diagnostics.Debug.Print("Event: WindowActivate {0}", Pres.FullName); if (m_AlfrescoPane != null) { m_AlfrescoPane.OnDocumentChanged(); } }