How to remove all pilcrons between all tables?

A

avkokin

Hello.
There is some tables into document. They has separated one (or more)
the pilcron. The columns thouse tables is identicaly. The tables is
identicaly.
Question: how to delete all the pilcrons between the tables?
I use folowing macro but it don't worked (last pilcron don't delete)
and cycle.
Sub delParSignBetweenTables()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p"
.Format = False
.Forward = True
.Wrap = wdFindContinue
.Execute
While .Found
Selection.Delete wdCharacter, 1
.Execute
Wend
End With
End Sub
Thank you very much.
 
M

macropod

Hi avkokin,

You can't remove the last pilcrow from a document. All others, yes, but not the last one.

You can also replace:
While .Found
Selection.Delete wdCharacter, 1
.Execute
Wend
with
..Replacement.Text = ""
 
A

avkokin

You can't remove the last pilcrow from a document. All others, yes, but not the last one.
You can also replace:
   While .Found
      Selection.Delete wdCharacter, 1
      .Execute
   Wend
with

Thank you. But...

If I use into line "with selection.find"
.Replacement.Text = ""
then it is all the same has cycle (on last pilcrow sign).
Maybe I'm uncorrectly doing?
 
A

avkokin

No, I replaced operator While...Wend with .Replacement.Text="", but it
didn't deleted pilcrow. Give me any others ideas, please. Thank you.
 
H

Helmut Weber

Hi Anton,

as deleting paragraph marks of paragraphs,
which contain text, doesn't make much sense,
I'm assuming, the paragraphs between the tables are empty,
and you want to join the tables.
Furthermore, a paragraph mark preceding a table
is something special and cannot be replaced by "",
therefore I'm deleting ranges between tables.

Here we go:

Sub test6666()
Dim oTbl1 As Table
Dim oTbl2 As Table
Dim rtmp As Range
Dim l As Long
Set rtmp = Selection.Range
With ActiveDocument
l = .Tables.Count
While l > 1
Set oTbl2 = ActiveDocument.Tables(.Tables.Count)
Set oTbl1 = ActiveDocument.Tables(.Tables.Count - 1)
rtmp.start = oTbl1.Range.End
rtmp.End = oTbl2.Range.start
' rtmp.Select
rtmp.Delete
' With rtmp.Find ' does not work
' .Text = Chr(13)
' .Replacement.Text = ""
' .Execute Replace:=wdReplaceAll
' End With
l = .Tables.Count
Wend
End With
End Sub
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
H

Helmut Weber

better:

Set oTbl2 = .Tables(.Tables.Count)
Set oTbl1 = .Tables(.Tables.Count - 1)
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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