Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code in a VB6 program:
Function BoldMarkup(R As Range) As String Dim N As Long Dim S As String Dim InBold As Boolean If R.Cells.Count 1 Then Exit Function End If If R.HasFormula = True Then Exit Function End If If Len(R.Text) = 0 Then Exit Function End If If Len(R.Text) = 1 Then If R.Characters(1, 1).Font.Bold Then BoldMarkup = "<b" & R.Text & "</b" Exit Function End If End If For N = 1 To Len(R.Text) If R.Characters(N, 1).Font.Bold = True Then If InBold = False Then S = S & "<b" & R.Characters(N, 1).Text InBold = True Else S = S & R.Characters(N, 1).Text If N = Len(R.Text) Then S = S & "</b" End If End If Else If InBold = True Then S = S & "</b" & R.Characters(N, 1).Text InBold = False Else S = S & R.Characters(N, 1).Text End If End If Next N BoldMarkup = S End Function Sub Test() Dim CellRange As Excel.Range For I = 1 To 200 For J = 1 To 11 Set CellRange = ExcelWorksheet.Cells(I, J) TextStr = BoldMarkup(CellRange) Next J Next I End Sub If I set the upper limit of the "For J" loop to 1 (instead of 11), the code works. However, when I have it loop on the first 11 columns in the worksheet, it gives me the following error: Unable to set the Text Property of the Characters class The error occurs the first time that "R.Characters(N, 1).Text" is referenced in the BoldMarkup function. I cannot figure out why I'm getting the error or what to do to get around it. Help! Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to set NumberFormat Property of Range class | Excel Programming | |||
Unable to set the Values property of the Series class | Charts and Charting in Excel | |||
unable to get match property of WorksheetFunction class | Excel Programming | |||
Unable to get the PivotFields property of the PivotTable Class | Excel Programming | |||
Unable to get the Text property of the WorksheetFunction class | Excel Programming |