I have the following code:

Sub quitarenter()
For cnt1 = 1 To characters.count
char = Selection.Characters(cnt1).Text
If char = Chr(10) Then
Characters(cnt1) = Chr(13)
End If
Next.

what I want to do is:
I'm importing from acrobat reader to word, a lot of (change of line)
characters appear in between sentences, what I want to do is to delete those
(change of line) (chr 10) to space and continuation of the sentence.

Remarks,
I ran the code and it did not work, frist of all the "characterscount" after
the "for" didnt work, and then the code never found chr(10) (change of line)

any suggestions??
TIA

Re: what character is enter by Helmut

Helmut
Sun Jan 13 06:07:03 PST 2008

Hi filo666,

a linebreak in Word is chr(11),
no matter what the help says.

It is chr(10) in Excel and maybe in other applications as well.

A character(13) is exactly that, chr(13),
but not a paragraph mark.

Try replacing chr(11) by "^p", like that:

Sub Test6777()
Dim rTmp As Range
Set rTmp = Selection.Range
With rTmp.Find
.Text = "^11"
.Replacement.Text = "^p"
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub

See also: http://gregmaxey.mvps.org/Replace_With_Paragraph.htm

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: what character is enter by filo666

filo666
Sun Jan 13 11:14:01 PST 2008

Thanks for answering, but it did not work out, any idea???

"Helmut Weber" wrote:

> Hi filo666,
>
> a linebreak in Word is chr(11),
> no matter what the help says.
>
> It is chr(10) in Excel and maybe in other applications as well.
>
> A character(13) is exactly that, chr(13),
> but not a paragraph mark.
>
> Try replacing chr(11) by "^p", like that:
>
> Sub Test6777()
> Dim rTmp As Range
> Set rTmp = Selection.Range
> With rTmp.Find
> .Text = "^11"
> .Replacement.Text = "^p"
> .MatchWildcards = True
> .Execute Replace:=wdReplaceAll
> End With
> End Sub
>
> See also: http://gregmaxey.mvps.org/Replace_With_Paragraph.htm
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
>

Re: what character is enter by Helmut

Helmut
Sun Jan 13 14:19:51 PST 2008

Hi,

>it did not work out, any idea???

which is kind of a spare error description,
if there is an error at all.

see in addition:
http://www.google.com/custom?hl=de&cof=S:http://www.mvps.org%3BL:http://www.mvps.org/images/mvp.gif%3BLH:89%3BLW:108%3B&sitesearch=mvps.org&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=clean+web&spell=1

and
http://gregmaxey.mvps.org/Clean_Up_Text.htm

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: what character is enter by Helmut

Helmut
Sun Jan 13 14:24:34 PST 2008

that first link should be

http://word.mvps.org/FAQs/Formatting/CleanWebText.htm

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: what character is enter by filo666

filo666
Mon Jan 14 01:27:01 PST 2008

It did not appear any error wathsoever, but it did not change anything,
please take an acrobat file and try, maybe the though character is not the
right one; by the way, how is Bavaria, is it a nice place??? it sound to me
like a interesting place!!!

"Helmut Weber" wrote:

> that first link should be
>
> http://word.mvps.org/FAQs/Formatting/CleanWebText.htm
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
>

Re: what character is enter by filo666

filo666
Mon Jan 14 02:14:00 PST 2008

please note the following code:

For cnt1 = 1 To 10000
char = ActiveDocument.Characters(cnt1)
If char = Chr(cnt1) Then
stop
End If

I determine that the character is char(13) so my new code is:

Sub quitarenter()
'ActiveDocument.Characters(1).Text = Chr(7)
For cnt1 = 1 To 10000000000#
char = ActiveDocument.Characters(cnt1)
ActiveDocument.Characters(cnt1).Select
If char = Chr(13) Then
ActiveDocument.Characters(cnt1).Text = Chr(7) & " "
End If
Next
End Sub

it takes hours to finish a 100 page document, could you help me to fasten it.

thanks.

"filo666" wrote:

> It did not appear any error wathsoever, but it did not change anything,
> please take an acrobat file and try, maybe the though character is not the
> right one; by the way, how is Bavaria, is it a nice place??? it sound to me
> like a interesting place!!!
>
> "Helmut Weber" wrote:
>
> > that first link should be
> >
> > http://word.mvps.org/FAQs/Formatting/CleanWebText.htm
> >
> > --
> >
> > Greetings from Bavaria, Germany
> >
> > Helmut Weber, MVP WordVBA
> >
> > Vista Small Business, Office XP
> >

Re: what character is enter by Tony

Tony
Mon Jan 14 03:54:32 PST 2008

The first thing to do is to ascertain what the character is. It would appear
it isn't chr(10). Select one of the characters and then go to the immediate
window in the VBE (Alt+F11, Ctrl+G) and type ?asc(selection). It will tell
you the character number.

Secondly why are you trying to replace it with chr(13), a carriage return?
You say you want a space, so use a space.

--
Enjoy,
Tony

"filo666" <filo666@discussions.microsoft.com> wrote in message
news:433687F2-7F8D-4D6A-ACAC-F0321F5B0D83@microsoft.com...
>I have the following code:
>
> Sub quitarenter()
> For cnt1 = 1 To characters.count
> char = Selection.Characters(cnt1).Text
> If char = Chr(10) Then
> Characters(cnt1) = Chr(13)
> End If
> Next.
>
> what I want to do is:
> I'm importing from acrobat reader to word, a lot of (change of line)
> characters appear in between sentences, what I want to do is to delete
> those
> (change of line) (chr 10) to space and continuation of the sentence.
>
> Remarks,
> I ran the code and it did not work, frist of all the "characterscount"
> after
> the "for" didnt work, and then the code never found chr(10) (change of
> line)
>
> any suggestions??
> TIA


Re: what character is enter by HelmutWeber

HelmutWeber
Mon Jan 14 05:05:01 PST 2008

Hi Filo,

so you are copying text from a pdf-file,
paste it into Word and want to get rid of
the paragraph marks (chr13).


Try:

Sub Test456()
Dim rtmp As Range
Set rtmp = ActiveDocument.Range
With rtmp.Find
.Text = "^p"
.Replacement.Text = " " ' or whatever
.Execute Replace:=wdReplaceAll
End With
End Sub

or

Sub Test456()
Dim rtmp As Range
Set rtmp = ActiveDocument.Range
With rtmp.Find
.Text = Chr(13)
.Replacement.Text = Chr(32) ' or whatever
.Execute Replace:=wdReplaceAll
End With
End Sub

You don't even need a macro for that.

But note, that this will leave you
with a one-paragraph document!

I see no way, to distinguish programmatically
between paragraph marks you want to keep
and those you want to delete.

So better use the selection-object.

Sub Test456()
With Selection.Range.Find
.Text = Chr(13)
.Replacement.Text = Chr(32) ' or whatever
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
End Sub

Yes, Bavaria is a good place to live.

--
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)