Consulting

Results 1 to 3 of 3

Thread: Solved: ByRef argument type mismatch error!!!

  1. #1

    Solved: ByRef argument type mismatch error!!!

    Hi All,

    I'm unable to figureout what type I need to declare for cellFrame,Here I'm giving the code

    Set cellFrame = shpGrpTable.Table.Cell(1, 1).Shape.TextFrame
    Call FormatMyCell(cellFrame, "GROUP", 14, "Arial", msoTrue, 16777215, msoAnchorCenter, 3, True, 13382451)

    --

    Sub FormatMyCell(MyCell As Shape, Text As String, FontSize As Single, _
    FontName As String, FontBold As Boolean, FontColor As MsoRGBType, HoriAnchor As MsoHorizontalAnchor, VertAnchor As MsoVerticalAnchor, FillProp As Boolean, FillColor As MsoRGBType)
    With MyCell
    If Text <> "" Then
    .Text = Text
    With .Font
    .Size = FontSize
    .Name = FontName
    .Color.RGB = FontColor
    .Bold = FontBold
    End With
    End If
    .HorizontalAnchor = MsoHorizontalAnchor
    .VerticalAnchor = MsoVerticalAnchor

    If FillProp = True Then
    .Solid
    .ForeColor.RGB = FillColor
    End If
    End With

    End Sub

    ---

    Thanks,
    Sharath.

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi Sharath

    The mismatch is because you're declaring the object as a Shape, "MyCell As Shape", but setting the reference to a shape's textframe,
    Set cellFrame = shpGrpTable.Table.Cell(1, 1).Shape.TextFrame
    Depending on where you use the code , you may get an error if you declare a textframe oject since a shape may not have one, so the best option would be[VBA]Sub test()

    End Sub
    Set cellFrame = shpGrpTable.Table.Cell(1, 1).Shape
    Call FormatMyCell(cellFrame, "GROUP", 14, "Arial", msoTrue, 16777215, msoAnchorCenter, 3, True, 13382451)
    End Sub

    Sub FormatMyCell(MyCell As Shape, Text As String, FontSize As Single, _
    FontName As String, FontBold As Boolean, FontColor As MsoRGBType, HoriAnchor As MsoHorizontalAnchor, VertAnchor As MsoVerticalAnchor, FillProp As Boolean, FillColor As MsoRGBType)
    If MyCell.HasTextFrame Then
    With MyCell.TextFrame.TextRange
    If .Text <> "" Then
    .Text = Text
    .Font.Size = FontSize
    .Font.Name = FontName
    .Color.RGB = FontColor
    .Bold = FontBold
    End If
    End With
    With MyCell.TextFrame
    .HorizontalAnchor = MsoHorizontalAnchor
    .VerticalAnchor = MsoVerticalAnchor
    End With
    If FillProp = True Then
    With MyCell.Fill
    .Solid = True
    .ForeColor.RGB = FillColor
    End If
    End With

    End Sub[/VBA]
    K :-)

  3. #3
    Thanks Killian.

    It is working fine.

Posting Permissions

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