Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trying to Call a Function (VBA/Powerpoint/2000)

    Hi. I was hoping someone could point in the right direction (that is if i can explain it correctly) as i'm now moving into uncharted territory in my knowledge of VBA

    I have a procedure that needs to call on a function.

    the line in my procedure is

    Call WMColor("155, 155, 155", "155, 155, 155"), where the variables are the fill colour of a shape and the line color.


    the function it's calling is

    Function WMColor(strFill As String, strLine As String) As Boolean
    Dim oSel As PowerPoint.Selection
    Set oSel = ActiveWindow.Selection
    Select Case oSel.Type

    Case ppSelectionNone
    ActiveWindow.Selection.SlideRange.Shapes.AddShape( msoShapeRectangle, 0#, 451.25, 176.25, 88.75).Select
    With ActiveWindow.Selection.ShapeRange
    .Fill.Visible = msoTrue
    .Fill.Solid
    .Fill.ForeColor.RGB = strFill
    .Line.Visible = msoTrue
    .Line.ForeColor.RGB = strLine
    .Line.BackColor.RGB = RGB(255, 255, 255)
    .TextFrame.AutoSize = ppAutoSizeNone
    End With

    etc. etc. etc.

    (there are other cases following, but i've omitted those)

    All works fine, but then the function stops with the line ".Fill.ForeColor.RGB = strFill" and goes back to the procedure.

    How do I get it run the whole Function or am i grabbing the wrong end of the stick!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Trying to Call a Function (VBA/Powerpoint/2000)

    The RGB property is a long integer, not a string. Try this:

    Function WMColor(lngFill As Long, lngLine As Long) As Boolean
    Dim oSel As PowerPoint.Selection
    Set oSel = ActiveWindow.Selection
    Select Case oSel.Type
    Case ppSelectionNone
    ActiveWindow.Selection.SlideRange.Shapes. _
    AddShape(msoShapeRectangle, 0#, 451.25, 176.25, 88.75).Select
    With ActiveWindow.Selection.ShapeRange
    .Fill.Visible = msoTrue
    .Fill.Solid
    .Fill.ForeColor.RGB = lngFill
    .Line.Visible = msoTrue
    .Line.ForeColor.RGB = lngLine
    .Line.BackColor.RGB = RGB(255, 255, 255)
    .TextFrame.AutoSize = ppAutoSizeNone
    End With
    ...
    End Select
    End Function

    and call it like this:

    Call WMColor(RGB(155, 155, 155), RGB(155, 155, 155))

    or

    Call WMColor(vbYellow, vbRed)

  3. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Trying to Call a Function (VBA/Powerpoint/2000)

    Brilliant Hans.

    It's now working brilliantly.

    I've only just learnt about variables etc, and i've already cut 15 pages of code down to 1!!!

    Many thanks again.

    Thom

Posting Permissions

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