Dans son message, notre ami < Al > nous laissait savoir que :
In this message, our friend < Al > informed us that:
Cell markers are tricky, especially with find and repalce.
I do not know if there is a way to refer to a cell marker in the built-in
Find dialog... But with VBA you can play with the following code to solve
your problem.
'_______________________________________
Dim myCell As Cell
Dim CellText As String
Dim NewText As String
Dim SearchStr As String
SearchStr = Chr(13) & Chr(13) & Chr(7)
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
For Each myCell In .Range.Cells
CellText = myCell.Range.Text
If Len(CellText) > 2 Then
If Right(CellText, 3) = SearchStr Then
NewText = Replace(CellText, _
SearchStr, Chr(7))
myCell.Range.Text = NewText
End If
End If
Next myCell
Next i
End With
'_______________________________________
Good luck ;-)
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarci...@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
You can't search for the end-of-cell markers.
If you copy the text from a cell into a string, the end-of-cell marker shows
up as Chr(13) & Chr(7) ... and the end-of row-marker as two of these.
But neither searching for ^13^7 nor for ^13 or ^7 will find them, so you
can't deal with your problem with Find/Replace.
I wrote to MSw...@microsoft.com about it in the past -- It would really be
nice if you could find the end-of-cell markers with Find/Replace.
It's very doubtful that this will ever come to pass though, no matter how
many people request it. That's the Curse of Compatibility, which makes Word
worse and worse with each new version.
With VBA, you can loop the cells and delete the trailing paragraph marks; a
macro that does this for all cells in all tables:
Dim tableLoop as Table
Dim cellLoop As Cell
For each tableLoop in ActiveDocument.tables
For Each cellLoop In tableLoop.Range.Cells
While Right(cellLoop.Range.Text, 3) = Chr(13) & Chr(13) & Chr(7)
cellLoop.Range.Characters.Last.Previous.Delete
Wend
Next cellLoop
Next tableLoop
Maybe you might be able to write a faster macro if your tables are very
simple (no merged cells, no formatting except styles, no more than one
paragraph except for the trailing ś marks) by copying the text of a table
into a string (strTable=tableLoop.Range.Text), deleting the trailing
paragraph marks with string functions, and copying back the text.
Though if you want to set tableLoop.Range.Text=strTable, it's expected that
cells are delimited by tabs (instead of end-of-cell markers), and rows by
paragraph marks, so it would get a bit messy.
Regards,
Klaus
Klaus:
Thank you for the VBA.
It worked great.
Al