[vb excel] grootte 'opmerkingen'

Pagina: 1
Acties:
  • 128 views sinds 30-01-2008
  • Reageer

  • sjongenelen
  • Registratie: Oktober 2004
  • Laatst online: 20-07 20:20
ik wil in excel 2003 (visual basic) een groupwise mailbox inlezen.

Dit lukt, via een form lees ik de folders en mails uit de mailbox, filter er de emailadressen uit (undelivered mail returned to sender) de bodytext van de mail en plaats dit telkens in een nieuwe rij.

output is als volgt:


emailadres1 "mailbox is vol"
emailadres2 "mailbox bestaat niet meer"
emailadres3 "anders"

bij "anders" laat ik automatisch een 'opmerking' plaatsen, met daarin de totale bodytext.
Helaas is de bodytext niet altijd even groot (verschillende mailer-deamons) dus zou ik graag de grootte van het opmerkingveld "automatisch" hebben

de code waarmee ik de opmerking plaats is:
code:
1
excel.application.cells(teller, 2).addcomment (.bodytext)

nu kan ik wel via:
code:
1
excel.windows.application.cells.comment.shape
de height en width aanpassen, maar hoe krijg ik dit automatisch voor elke cel?

you had me at EHLO


  • onkl
  • Registratie: Oktober 2002
  • Laatst online: 23:07
Uit vba help:
Changes the width of the columns in the range or the height of the rows in the range to achieve the best fit.

expression.AutoFit
expression Required. An expression that returns a Range object. Must be a row or a range of rows, or a column or a range of columns. Otherwise, this method generates an error.

Remarks
One unit of column width is equal to the width of one character in the Normal style.

Example
This example changes the width of columns A through I on Sheet1 to achieve the best fit.

Worksheets("Sheet1").Columns("A:I").AutoFit

This example changes the width of columns A through E on Sheet1 to achieve the best fit, based only on the contents of cells A1:E1.

Worksheets("Sheet1").Range("A1:E1").Columns.AutoFit

  • sjongenelen
  • Registratie: Oktober 2004
  • Laatst online: 20-07 20:20
volgens mij, als ik me niet vergis, gaat dit alleen om de breedte v/d cell... niet van de opmerking hierbij..!

you had me at EHLO


Verwijderd

je kan ook sheets(1).range("a2:e8") of zoiets gebruiken natuurlijk.
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
sub CommentaarToolTipGrootte()
  Dim CelCommentaar As Comment
  Dim CommentaarCel As Range
  
  For Each CommentaarCel In ActiveSheet.UsedRange.Cells
    Set CelCommentaar = CommentaarCel.Comment
    If Not CelCommentaar Is Nothing Then
      CelCommentaar.Shape.Height = 100
      CelCommentaar.Shape.Width = 100
    End If
    Set CelCommentaar = Nothing
  Next
End Sub

  • sjongenelen
  • Registratie: Oktober 2004
  • Laatst online: 20-07 20:20
ja, maar dan geef je het commentaar/opmerkingenveld een vaste grootte..!?

de grootte vd lappen tekst varieert nogal namenlijk.

[ Voor 27% gewijzigd door sjongenelen op 25-01-2007 16:09 ]

you had me at EHLO


Verwijderd

ah, ik had het eventjes anders geïnterpreteerd. zo dan:
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
Sub CommentaarToolTipGrootte()
  Dim CelCommentaar As Comment
  Dim CommentaarCel As Range
  
  For Each CommentaarCel In ActiveSheet.UsedRange.Cells
    Set CelCommentaar = CommentaarCel.Comment
    If Not CelCommentaar Is Nothing Then
      CelCommentaar.Shape.TextFrame.AutoSize=True
    End If
    Set CelCommentaar = Nothing
  Next
End Sub

  • sjongenelen
  • Registratie: Oktober 2004
  • Laatst online: 20-07 20:20
code:
1
ActiveCell.Comment.Shape.TextFrame.Autosize = True

moet ik dus hebben :)

morgen op 't werk ff testen :D


Heb ik een If statement van gemaakt, een flag bij het maken van het commentaar, en dan

if flag = true dan autosize toepassen.

EDIT2:

Zie hier het probleem:
Afbeeldingslocatie: http://img252.imageshack.us/img252/7884/voorbeeldrc2.th.png

met die autosize wordt de breedte v/d CELL alsnog aangepast. het moet de comment zijn...!

[ Voor 82% gewijzigd door sjongenelen op 26-01-2007 10:49 ]

you had me at EHLO


  • sjongenelen
  • Registratie: Oktober 2004
  • Laatst online: 20-07 20:20
ff een klein schopje vanwege de aanpassing, ik ga dadelijk naar huis, en thuis kan ik de groupwise box niet benaderen.

you had me at EHLO

Pagina: 1