Finding where to insert special characters

F

Francis Hookham

(Referring to the text below the line)



Until recently a list of meetings was sent out as a printable .rtf file. Now
we have a Meetings page on our website but I still have to send out a
printable document or hard copy to a few members who do not have a net
connection.



Having copied the Meeting page and pasted into Word as plain text I need to
compress each event into a single paragraph, with a Manual Line Break
separating everything after the meeting subject. Unfortunately it is beyond
me to do this other than manually because the line break needs to come
before Host or Contact or Cashier or Reception, whichever is first.
Sometimes there is only a Contact, sometimes there is a Host and sometimes
there is neither so the Cashier comes first.



With earlier MVP help I now have a macro which recognises the date and time
and places a tab between date and time and between time and venue. I doubt
we shall ever be able to automatically put a tab between venue, meal and
speaker.



However it should be possible to put a manual line break ahead of whichever
comes first of Host, Contact, Cashier or Reception.



Then, I wonder if there is a way of replaceng the paragraph marks with a ",
" between each remaining item.



Taking the first event:



29.08.2006 13:00 University Arms Hotel Lunch (frugal) Mark
Oliver, The work of Cambridgeshire Trading Standards Department

Host: Ben Jupp

Cashier: Graeme Minto

Reception: Stan Webster and Ian Purdy



Would end up as:



29.08.2006 13:00 University Arms Hotel Lunch (frugal) Mark
Oliver, The work of Cambridgeshire Trading Standards Department
Host: Ben Jupp, Cashier: Graeme Minto, Reception: Stan Webster and Ian Purdy



Many thanks and apologies for this long winded posting - I suppose the
problem is that I am able to write a series of IF statements in this
situation. Maybe I shall have to try in XL



Francis Hookham





29.08.2006 13:00 University Arms Hotel Lunch (frugal) Mark
Oliver, The work of Cambridgeshire Trading Standards Department

Host: Ben Jupp

Cashier: Graeme Minto

Reception: Stan Webster and Ian Purdy

03.09.2006 Grafham Water RYLA Week RYLA - the Rotary Youth
Leadership Award at Graffham Water, 2-9 September, all welcome on Sunday,
3rd, to see what it is all about

Contact: Victor Bugg

05.09.2006 12:00 University Arm Hotel ISC meeting
International Service Committee meeting at the UAH in room to be advised

05.09.2006 13:00 University Arms Hotel Lunch meeting
Murray Morse, Editor Cambridge Evening News, Developments of the CEN

Host: Charles Hewitson

Cashier: John Grieve

Reception: Tony Newall

05.09.2006 18:15 CUP Council meeting Council Meeting at
CUP, Shaftesbury Rd. All members are welcome

10.09.2006 TBA Sunday Walk Put this date in your diary for the
Sunday Walk No. 4 to be arranged by Bernard - details later

Contact: Bernard Townshend

12.09.2006 07:45 University Arms Hotel Breakfast
Fellowship meeting

Cashier: Charles Hewitson

Reception: Jim Lamb
 
G

Graham Mayor

It may be easier to simply use a selection of replace functions. Something
along the lines of the following shouldn't be far off the mark.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9]{2}.[0-9]{2}.[0-9]{4})"
.Replacement.Text = "#@#@#@\1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "(^13)@"
.Replacement.Text = "\1"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^13"
.Replacement.Text = ", "
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "#@#@#@"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "[, ]{1,}(^13)"
.Replacement.Text = ".\1"
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.WholeStory
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 12
End With
Selection.EndKey Unit:=wdStory


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
F

Francis Hookham

Many thanks Graham - I am making progress.

How can I find the second Tab Character ^t in a paragraph and replace it
with a Manual Line Break ^l through out the text?

I might want to replace the third Tab Character, rather than the second -
will it be obvious from your code how to find a particular tab character
(2nd, 3rd, 4th) within the paragraph? This would answer a problem in another
regular need to convers tab separated text.

Many thanks

Francis


Graham Mayor said:
It may be easier to simply use a selection of replace functions. Something
along the lines of the following shouldn't be far off the mark.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9]{2}.[0-9]{2}.[0-9]{4})"
.Replacement.Text = "#@#@#@\1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "(^13)@"
.Replacement.Text = "\1"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^13"
.Replacement.Text = ", "
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "#@#@#@"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "[, ]{1,}(^13)"
.Replacement.Text = ".\1"
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.WholeStory
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 12
End With
Selection.EndKey Unit:=wdStory


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Francis said:
(Referring to the text below the line)



Until recently a list of meetings was sent out as a printable .rtf
file. Now we have a Meetings page on our website but I still have to
send out a printable document or hard copy to a few members who do
not have a net connection.



Having copied the Meeting page and pasted into Word as plain text I
need to compress each event into a single paragraph, with a Manual
Line Break separating everything after the meeting subject.
Unfortunately it is beyond me to do this other than manually because
the line break needs to come before Host or Contact or Cashier or
Reception, whichever is first. Sometimes there is only a Contact,
sometimes there is a Host and sometimes there is neither so the
Cashier comes first.


With earlier MVP help I now have a macro which recognises the date
and time and places a tab between date and time and between time and
venue. I doubt we shall ever be able to automatically put a tab
between venue, meal and speaker.



However it should be possible to put a manual line break ahead of
whichever comes first of Host, Contact, Cashier or Reception.



Then, I wonder if there is a way of replaceng the paragraph marks
with a ", " between each remaining item.



Taking the first event:



29.08.2006 13:00 University Arms Hotel Lunch
(frugal) Mark Oliver, The work of Cambridgeshire Trading Standards
Department
Host: Ben Jupp

Cashier: Graeme Minto

Reception: Stan Webster and Ian Purdy



Would end up as:



29.08.2006 13:00 University Arms Hotel Lunch
(frugal) Mark Oliver, The work of Cambridgeshire Trading Standards
Department Host: Ben Jupp, Cashier: Graeme Minto, Reception: Stan Webster
and
Ian Purdy


Many thanks and apologies for this long winded posting - I suppose the
problem is that I am able to write a series of IF statements in this
situation. Maybe I shall have to try in XL



Francis Hookham





29.08.2006 13:00 University Arms Hotel Lunch
(frugal) Mark Oliver, The work of Cambridgeshire Trading Standards
Department
Host: Ben Jupp

Cashier: Graeme Minto

Reception: Stan Webster and Ian Purdy

03.09.2006 Grafham Water RYLA Week RYLA - the Rotary Youth
Leadership Award at Graffham Water, 2-9 September, all welcome on
Sunday, 3rd, to see what it is all about

Contact: Victor Bugg

05.09.2006 12:00 University Arm Hotel ISC meeting
International Service Committee meeting at the UAH in room to be
advised
05.09.2006 13:00 University Arms Hotel Lunch meeting
Murray Morse, Editor Cambridge Evening News, Developments of the CEN

Host: Charles Hewitson

Cashier: John Grieve

Reception: Tony Newall

05.09.2006 18:15 CUP Council meeting Council
Meeting at CUP, Shaftesbury Rd. All members are welcome

10.09.2006 TBA Sunday Walk Put this date in your diary
for the Sunday Walk No. 4 to be arranged by Bernard - details later

Contact: Bernard Townshend

12.09.2006 07:45 University Arms Hotel Breakfast
Fellowship meeting

Cashier: Charles Hewitson

Reception: Jim Lamb
 
R

Russ

Francis,
Code below is one way of doing what you ask.
Many thanks Graham - I am making progress.

How can I find the second Tab Character ^t in a paragraph and replace it
with a Manual Line Break ^l through out the text?

Alter by changing what's in first set of parentheses in .Text string
i.e. to have it replace 3rd tab use "(*^t*^t*)(^t)"

Sub Macro9()
Dim aP As Paragraph
For Each aP In ActiveDocument.Paragraphs
With aP.Range.Find
.Text = "(*^t*)(^t)"
.Replacement.Text = "\1^l"
.MatchWildcards = True
.Execute Replace:=wdReplaceOne
End With
Next aP
End Sub
I might want to replace the third Tab Character, rather than the second -
will it be obvious from your code how to find a particular tab character
(2nd, 3rd, 4th) within the paragraph? This would answer a problem in another
regular need to convers tab separated text.

Many thanks

Francis


Graham Mayor said:
It may be easier to simply use a selection of replace functions. Something
along the lines of the following shouldn't be far off the mark.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9]{2}.[0-9]{2}.[0-9]{4})"
.Replacement.Text = "#@#@#@\1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "(^13)@"
.Replacement.Text = "\1"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^13"
.Replacement.Text = ", "
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "#@#@#@"
.Replacement.Text = "^p"
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "[, ]{1,}(^13)"
.Replacement.Text = ".\1"
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.WholeStory
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 12
End With
Selection.EndKey Unit:=wdStory


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Francis said:
(Referring to the text below the line)



Until recently a list of meetings was sent out as a printable .rtf
file. Now we have a Meetings page on our website but I still have to
send out a printable document or hard copy to a few members who do
not have a net connection.



Having copied the Meeting page and pasted into Word as plain text I
need to compress each event into a single paragraph, with a Manual
Line Break separating everything after the meeting subject.
Unfortunately it is beyond me to do this other than manually because
the line break needs to come before Host or Contact or Cashier or
Reception, whichever is first. Sometimes there is only a Contact,
sometimes there is a Host and sometimes there is neither so the
Cashier comes first.


With earlier MVP help I now have a macro which recognises the date
and time and places a tab between date and time and between time and
venue. I doubt we shall ever be able to automatically put a tab
between venue, meal and speaker.



However it should be possible to put a manual line break ahead of
whichever comes first of Host, Contact, Cashier or Reception.



Then, I wonder if there is a way of replaceng the paragraph marks
with a ", " between each remaining item.



Taking the first event:



29.08.2006 13:00 University Arms Hotel Lunch
(frugal) Mark Oliver, The work of Cambridgeshire Trading Standards
Department
Host: Ben Jupp

Cashier: Graeme Minto

Reception: Stan Webster and Ian Purdy



Would end up as:



29.08.2006 13:00 University Arms Hotel Lunch
(frugal) Mark Oliver, The work of Cambridgeshire Trading Standards
Department Host: Ben Jupp, Cashier: Graeme Minto, Reception: Stan Webster
and
Ian Purdy


Many thanks and apologies for this long winded posting - I suppose the
problem is that I am able to write a series of IF statements in this
situation. Maybe I shall have to try in XL



Francis Hookham





29.08.2006 13:00 University Arms Hotel Lunch
(frugal) Mark Oliver, The work of Cambridgeshire Trading Standards
Department
Host: Ben Jupp

Cashier: Graeme Minto

Reception: Stan Webster and Ian Purdy

03.09.2006 Grafham Water RYLA Week RYLA - the Rotary Youth
Leadership Award at Graffham Water, 2-9 September, all welcome on
Sunday, 3rd, to see what it is all about

Contact: Victor Bugg

05.09.2006 12:00 University Arm Hotel ISC meeting
International Service Committee meeting at the UAH in room to be
advised
05.09.2006 13:00 University Arms Hotel Lunch meeting
Murray Morse, Editor Cambridge Evening News, Developments of the CEN

Host: Charles Hewitson

Cashier: John Grieve

Reception: Tony Newall

05.09.2006 18:15 CUP Council meeting Council
Meeting at CUP, Shaftesbury Rd. All members are welcome

10.09.2006 TBA Sunday Walk Put this date in your diary
for the Sunday Walk No. 4 to be arranged by Bernard - details later

Contact: Bernard Townshend

12.09.2006 07:45 University Arms Hotel Breakfast
Fellowship meeting

Cashier: Charles Hewitson

Reception: Jim Lamb
 

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