Control the size of a Comment Box in Excel 2007 from Access 2007

B

Bill Sturdevant

In Access 2007, I create an Excel 2007 spreadsheet. I am successfully able
to add comments to cells with this code:
xlsheet.Cells(J, I + 1).Interior.ColorIndex = 4
xlsheet.Cells(J, I + 1).AddComment "Blah blah blah."
xlsheet.Cells(J, I + 1).Comment.Visible = False

I am successfully able to control the font properties of those comments with
this code:
For Each x In xlsheet.Comments
With x.Shape.TextFrame.Characters.Font
.Name = "Calibri"
.Size = 8
.Bold = False
End With
Next x

But, how do I control the SIZE of the comment boxes?
I have tried this code:
xlsheet.Cells(J, I + 1).Select
Selection.ShapeRange.ScaleHeight 2, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 2, msoFalse, msoScaleFromTopLeft

But, it fails with "Runtime error 438: Object doesn't support this property
or method".

I have references to Excel 12.0 and Office 12.0 in my Access ACCDB.
 
R

ryguy7272

Sub Comments_Size()
Dim MyComments As Comment
For Each MyComments In ActiveSheet.Comments
With MyComments
..Shape.Width = 200 'change this number to get size you want
..Shape.Height = 200 'change this number to get size you want
End With
Next ' comment
End Sub

Do you know how to control Excel from Access? If not, post back...

HTH,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top