none
PowerPoint 2010: Clearing Dirty Flag influences formatting of shapes RRS feed

  • General discussion

  • Hi,

    I've already posted this question in the german forums, but as I've received no reaction I'll try it again here. (Here is the original post: http://social.msdn.microsoft.com/Forums/de-DE/vstode/thread/83b7732e-055f-4964-bd58-f418ae6c4586 )

    I want to show you the problem with a minimal working example. The code puts a text in a textbox-shape and makes it smaller, if the text is too long for the shape. Afterwoods it clears the dirty flag of the presentation.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    using PowerPoint = Microsoft.Office.Interop.PowerPoint;
    using Office = Microsoft.Office.Core;
    
    namespace PowerPointAddIn1
    {
        public partial class ThisAddIn
        {
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                Application.AfterNewPresentation += new PowerPoint.EApplication_AfterNewPresentationEventHandler(PPTAfterPresentationNew);
            }
    
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #region VSTO generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }
            
            #endregion
    
    
    
            void PPTAfterPresentationNew(PowerPoint.Presentation Pres)
            {
                PowerPoint.Shape newShape = Pres.Slides[1].Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 20, 20, 200, 20);
                newShape.BackgroundStyle = Office.MsoBackgroundStyleIndex.msoBackgroundStylePreset11; //Background to better visualise the size of the shape            
    newShape.TextFrame2.AutoSize = Office.MsoAutoSize.msoAutoSizeTextToFitShape;
    newShape.TextFrame.TextRange.Text = "This text should be resized because it's too long.";
    
                Pres.Saved = Office.MsoTriState.msoTrue; //When you comment out this line, the code behaves correctly.        }
        }
    }

    The output to the slide is dependent on the "Pres.Saved.." line:

    You have to repaint the shape, to get the desired behaviour. But that again influences the dirty flag. Same thing happens if I save the Presentation using Pres.Save();

    Is this a bug? How can i assure that the AutoSize-Feature works correctly?

    Thanks a lot,

    Jeff

    Wednesday, September 12, 2012 8:00 AM

All replies

  • Hi Jeff, 

    Thank you for posting in the MSDN Forum.

    I have reported this issue internally. You'll be informed if there's any update.

    Much appreciate for your time and effort.

    Best regards,
    Quist


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 13, 2012 10:40 AM
    Moderator
  • Hi Jeff,

    According to the Engineer of product group, this issue will be fixed in later versions of Office. 

    Much appreciate for your time and effort.

    Best regards,
    Quist



    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, September 14, 2012 4:14 AM
    Moderator
  • Hi Quist,

    thanks for answering! Did the engineer specify 'later version'? Like, with a future patch of Office 2010 or like with Office 2013?

    Thanks,

    Jeff

    Friday, September 14, 2012 3:04 PM