locked
Using RGB for a Shape.Line.ForeColor in PowerPoint VBA? RRS feed

  • Question

  • Hello all,

    The following code produces an oval shape with a black line.  It's as if the RGB(255,0,0) is ignored.  Why is the oval line not colored red?

    Sub MakeShape()
        Dim sl As Slide
        Dim sh As Shape
        Dim roval As Shape
       
        For Each sl In ActivePresentation.Slides
            If sl.SlideNumber = 1 Then
                Set roval = sl.Shapes.AddShape(Type:=msoShapeOval, Left:=600, Top:=50, Width:=50, Height:=100)
                With roval
                    .Line.ForeColor.RGB = RGB(255, 0, 0)
                    .Line.Visible = msoTrue
                End With
            End If
        Next
    End Sub

    • Moved by Mark Liu-lxf Monday, September 10, 2012 5:26 AM (From:Visual Basic General)
    Friday, September 7, 2012 10:38 PM

All replies

  • you might try posting in one of the Office Forums. There is not one specific for PowerPoint, so here is the link to the General Forum

    “This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.”

    Friday, September 7, 2012 10:56 PM
  • Hello all,

    The following code produces an oval shape with a black line.  It's as if the RGB(255,0,0) is ignored.  Why is the oval line not colored red?

    Sub MakeShape()
        Dim sl As Slide
        Dim sh As Shape
        Dim roval As Shape
      
        For Each sl In ActivePresentation.Slides
            If sl.SlideNumber = 1 Then
                Set roval = sl.Shapes.AddShape(Type:=msoShapeOval, Left:=600, Top:=50, Width:=50, Height:=100)
                With roval
                    .Line.ForeColor.RGB = RGB(255, 0, 0)
                    .Line.Visible = msoTrue
                End With
            End If
        Next
    End Sub

    • Merged by Mark Liu-lxf Monday, September 10, 2012 5:26 AM duplicate thread
    Friday, September 7, 2012 11:05 PM
  • I tested and found your code working and creating oval shape with red line border.

    Best Regards,
    Asadulla Javed, Kolkata
    ---------------------------------------------------------------------------------------------
    Please do not forget to click “Vote as Helpful” if any post helps you and "Mark as Answer”if it solves the issue.

    Saturday, September 8, 2012 5:06 AM
    Answerer
  • Once I moved the ".Line.ForeColor.RGB = RGB(255, 0, 0)" after ".Line.Visible = msoTrue" it worked.  Not sure why this mattered.  Thanks!
    Tuesday, September 11, 2012 9:28 PM