I was not sure if this should go under Office Development, but that seemed to be VBA and not .net. If this is in the wrong place I apologize ahead of time. I have also posted this question to another forum with no replies.
I am trying to format bullet points during creation and I am having some issues. I cant seem to change the font style "on the fly". For the final document the formatting for each bullet changes, bullet to bullet.
Bullet 1
Bullet 2
Bullet 3
Bullet 4
Bullet 5
Bullet 6
I have a class that stores the bullet text and the format it should be. I just don't know how best to apply the formatting. I am thinking if I could select the last insert text I could apply the formatting then, but cant seem to figure that out either. Meaning how to select the last inserted text. I am using InsertAfter for the range. As you will see from the sections that are commented out, I cant just apply to the range or EVERY bullet in that range will adopt that style. Any help would be greatly appreciated.
I am trying to format bullet points during creation and I am having some issues. I cant seem to change the font style "on the fly". For the final document the formatting for each bullet changes, bullet to bullet.
Bullet 1
Bullet 2
Bullet 3
Bullet 4
Bullet 5
Bullet 6
I have a class that stores the bullet text and the format it should be. I just don't know how best to apply the formatting. I am thinking if I could select the last insert text I could apply the formatting then, but cant seem to figure that out either. Meaning how to select the last inserted text. I am using InsertAfter for the range. As you will see from the sections that are commented out, I cant just apply to the range or EVERY bullet in that range will adopt that style. Any help would be greatly appreciated.
Code:
Private Sub CreateBullets(ByVal reportInfo As ReportInformation)
wrdBulletsRange = wrdDocument.Bookmarks("StartBullets").Range
wrdBulletsRange.Select()
wrdBulletsRange.ListFormat.ApplyBulletDefault()
For Each bullet In reportInfo.BulletPoints
If bullet.FontStyle = "Normal" Then
wrdBulletsRange.InsertAfter(bullet.BulletText)
ElseIf bullet.FontStyle = "Italics" Then
'wrdBulletsRange.Font.Italic = 1
wrdBulletsRange.InsertAfter(bullet.BulletText)
'wrdBulletsRange.Font.Italic = 0
ElseIf bullet.FontStyle = "Bold" Then
'wrdBulletsRange.Font.Bold = 1
wrdBulletsRange.InsertAfter(bullet.BulletText)
'wrdBulletsRange.Font.Bold = 0
ElseIf bullet.FontStyle = "Underline" Then
'wrdBulletsRange.Font.Underline = 1
wrdBulletsRange.InsertAfter(bullet.BulletText)
'wrdBulletsRange.Font.Underline = 0
ElseIf bullet.FontStyle = "Italics Bold" Then
'wrdBulletsRange.Font.Italic = 1
'wrdBulletsRange.Font.Bold = 1
wrdBulletsRange.InsertAfter(bullet.BulletText)
'wrdBulletsRange.Font.Italic = 0
'wrdBulletsRange.Font.Bold = 0
ElseIf bullet.FontStyle = "Italics Underline" Then
'wrdBulletsRange.Font.Italic = 1
'wrdBulletsRange.Font.Underline = 1
wrdBulletsRange.InsertAfter(bullet.BulletText)
'wrdBulletsRange.Font.Italic = 0
'wrdBulletsRange.Font.Underline = 0
ElseIf bullet.FontStyle = "Bold Underline" Then
'wrdBulletsRange.Font.Bold = 1
'wrdBulletsRange.Font.Underline = 1
wrdBulletsRange.InsertAfter(bullet.BulletText)
'wrdBulletsRange.Font.Bold = 0
'wrdBulletsRange.Font.Underline = 0
End If
If bullet IsNot reportInfo.BulletPoints.Last Then
Dim newLine As String = Environment.NewLine
wrdBulletsRange.InsertAfter(newLine)
End If
Next
wrdBulletsRange.Font.Name = "Arial"
wrdBulletsRange.Font.Size = 10
End Sub