Consulting

Results 1 to 2 of 2

Thread: INSERT TEXT AND FORMAT AUTOSHAPE

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location

    INSERT TEXT AND FORMAT AUTOSHAPE

    In my worksheet I've added a shape and placed text in the shape. Now I want to format the shape by changing the fill and font. I cannot find any information on how to continue with the code for doing that from where I ended the last.
    At help wold be appreciated.

    I have this code

    #Sub AddRectangle()
    Dim shp As Shapes
    Set shp = ActiveSheet.Shapes
    With shp
    With .AddShape(msoShapeRoundedRectangle, 112, 135, 255, 23).TextFrame
    .Characters.Text = "The default period has been changed to September 2018"
    .HorizontalAlignment = xlHAlignLeft
    .VerticalAlignment = xlVAlignCenter
    End With
    End With
    Set shp = Nothing
    End Sub#

    What now? Where/how do I start the next thing - change the fill?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Sub AddRectangle()  
      Dim s As Shape
      Set s = ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 112, 135, 255, 23)
      With s.TextFrame
        .Characters.Text = "The default period has been changed to September 2018"
        .Characters.Font.Color = vbRed
        s.Fill.ForeColor.RGB = vbYellow
        .HorizontalAlignment = xlHAlignLeft
        .VerticalAlignment = xlVAlignCenter
      End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •