Excel comments not doing what i require

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,251
Office Version
  1. 2007
Platform
  1. Windows
Ive been playing hours on this but not getting anywhere.
Can you advise please where im going wrong.

This code below is currently in use.
I see the comments box/shape etc but altering the Font size nothing changes.
Font isnt Calibri
Shape Style Preset13 is blue at all.

Ive attached a screenshot of the comments box.
I get no run time errors etc so why is the code saying how it should be but the output is anythng but ?

Rich (BB code):
    If Len(sText) > 0 Then
        With oShape.TextFrame
            .Characters.Text = sText
            .Characters.Font.Name = "Calibri"
            .Characters.Font.Size = 12
            .Characters.Font.Bold = True
            .HorizontalAlignment = x1HAlignCenter
            .VerticalAlignment = x1VAlignCenter
            Shape.ShapeStyle = msoShapeStylePreset13
        End With
    End If
 

Attachments

  • 458.jpg
    458.jpg
    17.5 KB · Views: 11

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
how is oShape set in your code?

this works for me
- test on an empty sheet, select one or more cells and run code
VBA Code:
Sub FormatComments()
    Dim sText As String
   
    Dim Cel As Range
    Application.ScreenUpdating = False
    For Each Cel In Selection
        sText = Cel.Address(0, 0) & Chr(10) & Date & Chr(10) & Time
        On Error Resume Next
        Cel.AddComment
        On Error GoTo 0
        With Cel.Comment.Shape
            With .Fill
                .Visible = msoTrue
                .ForeColor.RGB = RGB(255, 255, 190)
                .OneColorGradient msoGradientDiagonalDown, 1, 0.95
            End With
            With .Line
                .ForeColor.RGB = RGB(100, 100, 100)
                .Style = msoLineThickBetweenThin
            End With
            With .TextFrame
                .HorizontalAlignment = xlHAlignCenter
                .VerticalAlignment = xlVAlignCenter
                .Characters.Text = sText
                With .Characters.Font
                    .Size = 12
                    .Name = "Calibri"
                    .Bold = True
                End With
            End With
            .AutoShapeType = msoShapeRoundedRectangle
        End With
    Next Cel
End Sub

But the code always fails with .ShapeStyle = msoShapeStylePreset13
 
Upvote 0
Morning,
Thanks for the reply but there must be something else going on with my code as the same happens.

When i change the RGB color i see no change on my worksheet.

I have supplied a copy of my worksheet here for you to see,please do the following.

On the wprksheet POSTAGE select OPEN FORM
Enter values in the textboxes, CUSTOMER, ITEM DESCRIPTION, EBAY USERNAME, TRACKING NUMBER then write some text in THAT LONG LOWER TEXTBOX.

Now select POSTAGE SHEET TRANSFER BUTTON

Select YES
Select OK
Select NO

Now select CLOSE FORM

Now look in the cell of last row column D

This is where the comment should be as per your code but it isnt.

Many thanks for your time.

Download My Excel File Here
 
Upvote 0
Testing it on a new sheet i see it working.
Thus i select a cell the code runs and i see the time etc.

Now need to edit is so it applies to my text when sent to cell at column D

I need to apply the code so the text is taken from TextBox10 & not the selected cell on worksheet
 
Last edited:
Upvote 0
Basically my code works in respect of me typing on the userform then sending it to my worksheet.

What i need only to be done is to format the look / style of the comments box itself,the rest has been done
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top