PDA

View Full Version : Conversion from Bullets and lists to HTML



monikamalik
12-27-2007, 07:35 AM
hi all

How can i convert bullets and lists in Corresponding HTML text.I can use a custom style to find range of text.I have already created it forr custom style,but how i can do same without custom styles.

Code i used in VB for custom styles :

Private Sub ConvertBullet(ByVal oRange As Word.Range, ByVal strBulletStyle As String)
Dim openingTag, closingTag, postFix
Dim bulletLevel As Integer
' bulletLevel = strBulletStyle.Substring(strBulletStyle.Length - 1, 1)
'bulletLevel = 0
If (strBulletStyle = "mainBullet") Then
openingTag = "<ul level='1'>"
closingTag = "</ul level='1'>"
bulletLevel = 1
ElseIf (strBulletStyle = "Level2Bullet") Then
openingTag = "<ul><ul type='square' level='2'>"
closingTag = "</ul level='2'></ul>"
bulletLevel = 1
ElseIf (strBulletStyle = "Numlist") Then
openingTag = "<ol level='1'>"
closingTag = "</ol level='1'>"
bulletLevel = 1
End If
If (bulletLevel = "1") Then
postFix = ""
Else
postFix = "<li>"
End If

With oRange.Find
.ClearFormatting()
.Replacement.ClearFormatting()
.Style = strBulletStyle
.Text = ""
.Replacement.Text = openingTag + "<li>^&</li>" + closingTag + postFix
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With

With oRange.Find
.Text = "^p"
.Replacement.Text = "</li><li>"
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With

End Sub