Hallo,
im unteren Beispiel soll der Text einer Textbox automatisch verkleinert werden, wenn er zu lang wird. Das ist auch der Fall, es sei denn man setzt danach noch das Flag
Presentation.Saved.
Das selbe Problem tritt auf, wenn ich stattdessen versuche, die Präsentation zu speichern mit Presentation.Save();
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; //Wunderschöner Hintergrund zur besseren Darstellung der Größe des Shapes
newShape.TextFrame2.AutoSize = Office.MsoAutoSize.msoAutoSizeTextToFitShape; //Text wird verkleinert, wenn er zu lange wird.
newShape.TextFrame.TextRange.Text = "Dieser Text sollte verkleinert werden weil er zu lange ist.";
Pres.Saved = Office.MsoTriState.msoTrue; //Diese Zeile auskommentieren, damit sich der obige Code richtig verhält.
}
}
}
Im folgenden Bild habe ich die jeweiligen Outputs gegenübergestellt:

Ist das ein Bug? Wie kann ich sicherstellen, dass das AutoSize dennoch richtig funktioniert?
Vielen dank,
Jeff