none
Run-time error '-2147024809 (80070057)': The specified value is out of range. RRS feed

  • Question

  • Hi guys,

    I am trying to create a rectangle and add a specific color to it in Powerpoint 2010 VBA and I get the above error when I try to do this

    myPres.Slides(count).Shapes.AddShape Type:=msoShapeRectangle, Left:=210, Top:=50, Width:=70, Height:=130
            myPres.Slides(count).Shapes(4).PictureFormat.TransparencyColor = RGB(34, 139, 34)

    Any idea how to fix it ? Or suggestions to use a different method ?

    I would really appreciate the favor guys !

    Thanks and regards.

    Monday, March 4, 2013 3:50 PM

Answers

  • TransparencyColor applies only to pictures and OLE objects, not to a rectangle. Try

        Dim myShape As Shape
        ...
        Set myShape = myPres.Slides(Count).Shapes.AddShape(Type:=msoShapeRectangle, Left:=210, Top:=50, Width:=70, Height:=130)
        myShape.Fill.ForeColor.RGB = RGB(34, 139, 34)
    


    Regards, Hans Vogelaar

    • Marked as answer by vbharath8 Monday, March 4, 2013 5:46 PM
    Monday, March 4, 2013 4:00 PM

All replies

  • Are you sure you have 4 shapes on Slides(Count)?  If you are adding them, you may need to change your 4 to another count.... from this

    myPres.Slides(count).Shapes(4).PictureFormat.TransparencyColor = RGB(34, 139, 34)

    to this, maybe

    myPres.Slides(count).Shapes(myPres.Slides(count).Shapes.Count).PictureFormat.TransparencyColor = RGB(34, 139, 34)

    Monday, March 4, 2013 3:58 PM
  • TransparencyColor applies only to pictures and OLE objects, not to a rectangle. Try

        Dim myShape As Shape
        ...
        Set myShape = myPres.Slides(Count).Shapes.AddShape(Type:=msoShapeRectangle, Left:=210, Top:=50, Width:=70, Height:=130)
        myShape.Fill.ForeColor.RGB = RGB(34, 139, 34)
    


    Regards, Hans Vogelaar

    • Marked as answer by vbharath8 Monday, March 4, 2013 5:46 PM
    Monday, March 4, 2013 4:00 PM
  • Yes, I have 3 other shapes and this is the 4th :)
    Monday, March 4, 2013 5:43 PM
  • Thanks a lot, Hans ! That worked perfectly.

    Could you point me to where I could find all the different funtions for a certain Object as Shapes ? And other objects too for that matter ?

    I tried looking in the powerpoint section of MSDN, but couldnt find this function.

    Once again, thanks a lot for the help !! :)


    • Edited by vbharath8 Monday, March 4, 2013 5:47 PM
    Monday, March 4, 2013 5:46 PM
  • The PowerPoint VBA help provides some of the information, but I don't know how to find all of it either...

    Regards, Hans Vogelaar

    Monday, March 4, 2013 8:53 PM
  • Hello I have a similar problem but with a class that hold a shape variable and a GET property crapping out when getting a Line shape. I have a collection of class ShapeTypes where a the get property shp_Obj() works for shapes of Textbox but crapps out on shape types of Line? Why?

    Public Property Get shp_Obj() As Shape
        If prvt_int_Ordinal = 13 Then
            MsgBox prvt_Shp_Shape.Name, , "prvt_Shp_Shape.Name"
         End If
     

    Set shp_Obj = prvt_Shp_Shape 'which is an internal variable of Shape

    On Error Resume Next

    End Property

    Public Property Set shp_Obj(param_Shp As Shape)


        If Me.Status <> cnst_int_Status_Null Then
            
            MsgBox "Property Set shp_Obj(param_Shp As Shape)", VbMsgBoxStyle.vbCritical, "cls_Part"
            Stop

        End If
        
        prvt_int_status = cnst_int_Status_Initialized

        Set prvt_Shp_Shape = param_Shp
        
        

    End Property

    Sunday, September 21, 2014 5:43 PM
  • I'm not sure I can answer that, but I'd need to see a copy of the presentation. Could you upload it to a site such as OneDrive or DropBox, share the uploaded file and post a link to the shared file in a reply?

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, September 21, 2014 8:52 PM