PDA

View Full Version : Solved: ByRef argument type mismatch error!!!



sharath
09-16-2005, 10:14 AM
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.

Killian
09-16-2005, 11:58 AM
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 beSub 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

sharath
09-16-2005, 12:20 PM
Thanks Killian.

It is working fine.