ich habe ein Kommentarfeld erzeugt, dass einen Text variabler länge beinhaltet soll.
Nun soll die Breite des Kommentarfeldes fest sein. Die Höhe darf (muss) dementsprechend angepasst werden.
Wie funktioniert dies in Excel? Hier meine Implementierung, die nicht bei Text funktioniert, die keinen Zeilenumbruch beinhalten:
Sheets().Cells().AddComment
Sheets().Cells().Comment.Visible = False
Sheets().Cells().Comment.Text Text:="Text variabler Länge mit Zeilenumbruch usw."
'Lasse Excel Auto-Formatieren
Sheets().Cells().Comment.Shape.TextFrame.AutoSize = True
'Speichere die "Auto" Breite
CommentWidth = Sheets().Cells().Comment.Shape.Width
'640 ist die Standardbreite, skaliere auf die Standardbreite
Sheets().Cells().Comment.Shape.ScaleWidth (640 / CommentWidth), msoFalse, msoScaleFromTopLeft
'Skaliere die Höhe anhand der Veränderung der Breite
Sheets().Cells().Comment.Shape.ScaleHeight (CommentWidth / 640), msoFalse, msoScaleFromTopLeft
Viele Grüsse
Chris