Einzelnen Beitrag anzeigen

luckystar85

Registriert seit: 21. Dez 2004
Ort: Rostock
138 Beiträge
 
Delphi 2009 Professional
 
#1

Positionierung von Textbox in Worddokument über Delphi

  Alt 29. Jan 2011, 15:18
Hi,
ich habe über RAD 2009 ein Programm erstellt das per Exportfunktion ein Word-Dokument über OLE generiert. Dazu soll in der Kopfzeile eine Textbox integriert werden, in der das Thema steht. Ich habe alles erstellt und unter Office 2010 funktioniert das alles fehlerfrei. Nur unter Office 2003 ist die Textbox nicht an der Stelle positioniert wie unter Office 2010. Ich habe auch schon versucht, wenn es Office 2003 ist, die Textbox einfach um 20-30 Pixel nach oben zu schieben aber auch das funktioniert nicht. Die Textbox bleibt immer an der gleichen Position. Per Mausaktion kann ich sie aber problemlos an die richtig Stelle verschieben.

Hier mein Code:
Delphi-Quellcode:
Procedure InsertWordTextBox(Const AWordApplication : TWordApplication; Const ALeft, ATop, AWidth, AHeight : Double);
Begin
  AWordApplication.Selection.HeaderFooter.Shapes.AddTextbox(msoTextOrientationHorizontal, ALeft, ATop, AWidth, AHeight, EmptyParam).Select(EmptyParam);
  AWordApplication.Selection.ShapeRange.TextFrame.TextRange.Select;
  AWordApplication.Selection.Collapse(EmptyParam);
  AWordApplication.Selection.ShapeRange.Fill.Visible := msoFalse;
  AWordApplication.Selection.ShapeRange.Line.Visible := msoFalse;
  AWordApplication.Selection.ShapeRange.Line.Weight := 0.75;
  AWordApplication.Selection.ShapeRange.Line.DashStyle := msoLineSolid;
  AWordApplication.Selection.ShapeRange.Line.Style := msoLineSingle;
  AWordApplication.Selection.ShapeRange.Line.Transparency := 0;
  AWordApplication.Selection.ShapeRange.Line.Visible := msoFalse;
  AWordApplication.Selection.ShapeRange.LockAspectRatio := msoFalse;
  AWordApplication.Selection.ShapeRange.TextFrame.MarginLeft := 0;
  AWordApplication.Selection.ShapeRange.TextFrame.MarginRight := 0;
  AWordApplication.Selection.ShapeRange.TextFrame.MarginTop := 0;
  AWordApplication.Selection.ShapeRange.TextFrame.MarginBottom := 0;
  AWordApplication.Selection.ShapeRange.RelativeHorizontalPosition := wdRelativeHorizontalPositionPage;
  AWordApplication.Selection.ShapeRange.RelativeVerticalPosition := wdRelativeVerticalPositionPage;
  AWordApplication.Selection.ShapeRange.Left := ALeft;
  AWordApplication.Selection.ShapeRange.Top := ATop;
  AWordApplication.Selection.ShapeRange.WrapFormat.Side := wdWrapBoth;
  AWordApplication.Selection.ShapeRange.WrapFormat.DistanceTop := AWordApplication.CentimetersToPoints(0);
  AWordApplication.Selection.ShapeRange.WrapFormat.DistanceBottom := AWordApplication.CentimetersToPoints(0);
  AWordApplication.Selection.ShapeRange.WrapFormat.DistanceLeft := AWordApplication.CentimetersToPoints(0.32);
  AWordApplication.Selection.ShapeRange.WrapFormat.DistanceRight := AWordApplication.CentimetersToPoints(0.32);
  AWordApplication.Selection.ShapeRange.WrapFormat.type_ := 3;
  AWordApplication.Selection.ShapeRange.TextFrame.AutoSize := Integer(False);
  AWordApplication.Selection.ShapeRange.TextFrame.WordWrap := Integer(True);
End;
Michael Klüber
Delphi ist was solides und besteht nicht wie C/C++ Quelltext nur aus Kommentaren.
  Mit Zitat antworten Zitat