Caporegime
- Joined
- 28 Jun 2007
- Posts
- 52,812
- Location
- Tamworth, UK
I have several bookmarks in a section of a word document. After the bookmarks are filled, I set the section to bullet.
Set myDoc = ActiveDocument
Set myrange = myDoc.Range( _
Start:=myDoc.Bookmarks("firstdefforename").Range.Start, _
End:=myDoc.Bookmarks("end").Range.End)
If myrange.ListFormat.ListType = wdListNoNumbering Then
myrange.ListFormat.ApplyBulletDefault
End If
I then remove any empty paragraphs from the field so that any incomplete bookmarks are removed to neaten the document.
Sub DeleteEmptyParagraphs()
Dim oPara As Word.Paragraph
Dim var
Dim SpaceCounter As Long
Dim oChar As Word.Characters
Set myDoc = ActiveDocument
Set myrange = myDoc.Range( _
Start:=myDoc.Bookmarks("firstdefforename").Range.Start, _
End:=myDoc.Bookmarks("end").Range.End)
For Each oPara In myrange.Paragraphs
If Len(oPara.Range) = 1 Then
oPara.Range.Delete
Else
SpaceCounter = 0
Set oChar = oPara.Range.Characters
For var = 1 To oChar.Count
If Asc(oChar(var)) = 32 Then
SpaceCounter = SpaceCounter + 1
End If
Next
If SpaceCounter + 1 = Len(oPara.Range) Then
' paragraph contains ONLY spaces
oPara.Range.Delete
End If
End If
Next
End Sub
I want to have carriage returns after each bookmarks to allow free text entry. However, I cannot set carriage returns in vb as the remove paragraph setting takes them out.
Any ideas?
Thanks.
Set myDoc = ActiveDocument
Set myrange = myDoc.Range( _
Start:=myDoc.Bookmarks("firstdefforename").Range.Start, _
End:=myDoc.Bookmarks("end").Range.End)
If myrange.ListFormat.ListType = wdListNoNumbering Then
myrange.ListFormat.ApplyBulletDefault
End If
I then remove any empty paragraphs from the field so that any incomplete bookmarks are removed to neaten the document.
Sub DeleteEmptyParagraphs()
Dim oPara As Word.Paragraph
Dim var
Dim SpaceCounter As Long
Dim oChar As Word.Characters
Set myDoc = ActiveDocument
Set myrange = myDoc.Range( _
Start:=myDoc.Bookmarks("firstdefforename").Range.Start, _
End:=myDoc.Bookmarks("end").Range.End)
For Each oPara In myrange.Paragraphs
If Len(oPara.Range) = 1 Then
oPara.Range.Delete
Else
SpaceCounter = 0
Set oChar = oPara.Range.Characters
For var = 1 To oChar.Count
If Asc(oChar(var)) = 32 Then
SpaceCounter = SpaceCounter + 1
End If
Next
If SpaceCounter + 1 = Len(oPara.Range) Then
' paragraph contains ONLY spaces
oPara.Range.Delete
End If
End If
Next
End Sub
I want to have carriage returns after each bookmarks to allow free text entry. However, I cannot set carriage returns in vb as the remove paragraph setting takes them out.
Any ideas?
Thanks.