Excel VB, ActiveCell.Characters - fontstyle

O

omsoft

I have several thousand rows of Excel data - text with various HTML tags
embedded within. The text size (cell length) is several thousand characters.

I am trying to replace these tags with Excel-style formatting. For example
make it <b>bold</b> to make it bold for partial string.

I read each character, distinguish tags e.g. <b> or </b>. note the start and
end position of bold and unbold. and then use the following code. sPos and
ePos are getting set correctly, but the string does not get bolded. Below is
the code I am using. j is the subscript in the for loop to go thru each
character.

If strTag = "</B>" And sPos > 0 Then
ePos = j - 1
With ActiveCell.Characters(sPos, ePos - sPos + 1).Font
.FontStyle = "Bold"
End With
startTag = False
endTag = False
sPos = 0
isBold = False
End If

Any help will be great.

Thanks.
 
O

omsoft

The code which causes the problem is as below.

Worksheets("Test").Range("B" & i).Value = _
Worksheets("Test").Range("B" & i).Value
& _
Chr(32) & vbCrLf 'Chr(10)

I have tried, vbnewline, chr(10), etc. but no difference. How do I tell it
to begin regular charcters (not bold) starting at this position in string.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top