Hello everyone,

All I need is the VB code at the bottom rewritten so that it will strip the red paragraph out of the following example document and place it in a text file:



Here is the example document:

John Doe
[email protected]
123-4567
Febuary 8, 2005

Jane Doe
12 Evergreen Rd.
Calgary, AB
S4S 5K9

Dear Jane,

RE: Document example
Mark: 46547
Country: Canada
Serial: 345Abb7
__________________________________

%%%Febuary 8, 2005,”345ABB7”,” TDLR”,Opposition,”preparing correspondence to Jane Doe regarding trademark renewal deadline approaching on March 17, 2005, seeking instructions regarding same”,”46547”,””,””

We note that there is approximately one month remaining within which to effect a timely renewal of the above captioned trademark registration. Should we not file the necessary renewal documents in advance of the March 17, 2005 deadline,


Yours very truly,

FURMAN & KALLIO



John Doe

JD
VB Code:
  1. Sub StripBillingInfo()
  2. On Error GoTo errorhandler
  3. 'set up variables
  4.        Dim SectionNumber As Integer
  5.        Dim RangeToSpike As Range
  6.        Dim AccumulatedText As String
  7. 'loop through sections
  8.        For SectionNumber = 1 To ActiveDocument.Sections.Count
  9. 'mark the first paragraph of the section, less the paragraph mark
  10.            Set RangeToSpike = _
  11.            ActiveDocument.Sections(SectionNumber).Range.Paragraphs.First.Range
  12.            RangeToSpike.MoveEnd wdCharacter, -1
  13.            If RangeToSpike.Start = RangeToSpike.End Then GoTo GetNextSection
  14.            If Mid(RangeToSpike.Text, 1, 3) <> "%%%" Then GoTo GetNextSection
  15. 'add the first paragraph to the spike, then delete it
  16.            RangeToSpike.MoveStart wdCharacter, 3
  17.            AccumulatedText = AccumulatedText & RangeToSpike.Text & vbCr
  18.            ActiveDocument.Sections(SectionNumber).Range.Paragraphs.First.Range.Delete
  19.            GetNextSection:
  20.        Next SectionNumber
  21. 'create a new document and dump the spike into it
  22. Documents.Open FileName:="e:\billing.txt", ConfirmConversions:=False, Format:=wdOpenFormatText
  23. Selection.EndKey wdStory
  24.           If Selection.Paragraphs.First.Range.Characters.Count > 1 Then
  25.                   Selection.InsertParagraph
  26.                   Selection.EndKey wdStory
  27.           End If
  28.           Selection.TypeText AccumulatedText
  29.           ActiveDocument.Close wdSaveChanges
  30.           errorhandler:
  31. End Sub

Any help is much appreciated