Reply
 
Thread Tools Display Modes
  #1   Report Post  
Jgrant Jgrant is offline
Junior Member
 
Posts: 2
Default Remove 2 Characters from the end of each line?

Hi

I'm wondering if it's possible to record a macro, or code one, or if there's some easy function that will remove two characters from the end of each line in Word. The lines are all different lengths.

Also, is there anyway to make Word remove blank lines? (No characters or anything. Just like if you hit enter twice. There's that line with nothing in it?)
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
DeanH DeanH is offline
external usenet poster
 
Posts: 1,862
Default Remove 2 Characters from the end of each line?

Firstly, try the quick and simple, select the text, click on the Centre align
icon (Ctrl+E), then the Left align icon (Ctrl+L), this usually gets rid of
any superfluous spaces and tabs from the start and end of paragraphs.
For multiple paragraphs you can use Find/Replace, using ^p^p for the find
and ^p for the replace, this will get rid of two paragraph marks and replace
with one.
See http://sbarnhill.mvps.org/WordFAQs/CleanWebText.htm for this and other
tips, also see http://gregmaxey.mvps.org/Clean_Up_Text.htm for a macro that
can help if you need to do this a lot.
--
Hope this helps
DeanH


"Jgrant" wrote:


Hi

I'm wondering if it's possible to record a macro, or code one, or if
there's some easy function that will remove two characters from the end
of each line in Word. The lines are all different lengths.

Also, is there anyway to make Word remove blank lines? (No characters
or anything. Just like if you hit enter twice. There's that line with
nothing in it?)




--
Jgrant

  #3   Report Post  
Jgrant Jgrant is offline
Junior Member
 
Posts: 2
Default

Alright, and how do I make it remove the last 2 characters? They are usually a - and a space, but it is sometimes something else, so I need it to remove the last 2 characters.
Quote:
Originally Posted by DeanH View Post
Firstly, try the quick and simple, select the text, click on the Centre align
icon (Ctrl+E), then the Left align icon (Ctrl+L), this usually gets rid of
any superfluous spaces and tabs from the start and end of paragraphs.
For multiple paragraphs you can use Find/Replace, using ^p^p for the find
and ^p for the replace, this will get rid of two paragraph marks and replace
with one.
See http://sbarnhill.mvps.org/WordFAQs/CleanWebText.htm for this and other
tips, also see http://gregmaxey.mvps.org/Clean_Up_Text.htm for a macro that
can help if you need to do this a lot.
--
Hope this helps
DeanH


"Jgrant" wrote:


Hi

I'm wondering if it's possible to record a macro, or code one, or if
there's some easy function that will remove two characters from the end
of each line in Word. The lines are all different lengths.

Also, is there anyway to make Word remove blank lines? (No characters
or anything. Just like if you hit enter twice. There's that line with
nothing in it?)




--
Jgrant
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Remove 2 Characters from the end of each line?

'Line' is a vague concept in Word as lines are totally dependent on text
flow and content. Are these 'lines' in fact paragraphs - terminated with a
paragraph mark ¶? In which case the following macro will both remove any
empty paragraphs and remove the last two characters (excluding the paragraph
mark) of each line

Sub Remove2Chars()
Dim oRng As Range
Dim i As Long
With ActiveDocument
For i = .Paragraphs.Count To 1 Step -1
Set oRng = .Paragraphs(i).Range
With oRng
.End = .End - 1
If .Text = "" Then .Delete
.Characters.Last.Delete
.Characters.Last.Delete
End With
Next i
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jgrant wrote:
Alright, and how do I make it remove the last 2 characters? They are
usually a - and a space, but it is sometimes something else, so I need
it to remove the last 2 characters.
DeanH;432759 Wrote:
Firstly, try the quick and simple, select the text, click on the
Centre align
icon (Ctrl+E), then the Left align icon (Ctrl+L), this usually gets
rid of
any superfluous spaces and tabs from the start and end of paragraphs.
For multiple paragraphs you can use Find/Replace, using ^p^p for the
find
and ^p for the replace, this will get rid of two paragraph marks and
replace
with one.
See http://sbarnhill.mvps.org/WordFAQs/CleanWebText.htm for this and
other
tips, also see http://gregmaxey.mvps.org/Clean_Up_Text.htm for a
macro that
can help if you need to do this a lot.
--
Hope this helps
DeanH


"Jgrant" wrote:
-

Hi

I'm wondering if it's possible to record a macro, or code one, or if
there's some easy function that will remove two characters from the
end
of each line in Word. The lines are all different lengths.

Also, is there anyway to make Word remove blank lines? (No characters
or anything. Just like if you hit enter twice. There's that line with
nothing in it?)




--
Jgrant
-



  #5   Report Post  
Jgrant Jgrant is offline
Junior Member
 
Posts: 2
Default

That didn't work at all.

I have this sort of a thing:
Victorian Hat Black - shop[4] - 650 -
Victorian Hat White - shop[4] - 650 -
Victorian Hat Green - shop[4] - 650 -
Victorian Hat Beige - shop[4] - 650 -

I want the last - removed, because it's pointless, but it is followed by a space.
Quote:
Originally Posted by Graham Mayor View Post
'Line' is a vague concept in Word as lines are totally dependent on text
flow and content. Are these 'lines' in fact paragraphs - terminated with a
paragraph mark ¶? In which case the following macro will both remove any
empty paragraphs and remove the last two characters (excluding the paragraph
mark) of each line

Sub Remove2Chars()
Dim oRng As Range
Dim i As Long
With ActiveDocument
For i = .Paragraphs.Count To 1 Step -1
Set oRng = .Paragraphs(i).Range
With oRng
.End = .End - 1
If .Text = "" Then .Delete
.Characters.Last.Delete
.Characters.Last.Delete
End With
Next i
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jgrant wrote:
Alright, and how do I make it remove the last 2 characters? They are
usually a - and a space, but it is sometimes something else, so I need
it to remove the last 2 characters.
DeanH;432759 Wrote:
Firstly, try the quick and simple, select the text, click on the
Centre align
icon (Ctrl+E), then the Left align icon (Ctrl+L), this usually gets
rid of
any superfluous spaces and tabs from the start and end of paragraphs.
For multiple paragraphs you can use Find/Replace, using ^p^p for the
find
and ^p for the replace, this will get rid of two paragraph marks and
replace
with one.
See http://sbarnhill.mvps.org/WordFAQs/CleanWebText.htm for this and
other
tips, also see http://gregmaxey.mvps.org/Clean_Up_Text.htm for a
macro that
can help if you need to do this a lot.
--
Hope this helps
DeanH


"Jgrant" wrote:
-

Hi

I'm wondering if it's possible to record a macro, or code one, or if
there's some easy function that will remove two characters from the
end
of each line in Word. The lines are all different lengths.

Also, is there anyway to make Word remove blank lines? (No characters
or anything. Just like if you hit enter twice. There's that line with
nothing in it?)




--
Jgrant
-


  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Remove 2 Characters from the end of each line?

As I indicated in my previous post, 'line' is a vague concept. The macro I
quoted removes the last two characters from each *paragraph*. Click the ¶
button (or CTRL+*) to display the hidden characters then see what the
makeup of the line endings really is and what the line termination
characters are.

However if all the lines are similar in layout to the list you quoted, you
can tackle it a different way

Use Replace with the wildcard option set to replace
(\] - [0-9]{3}) -
with
\1

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jgrant wrote:
That didn't work at all.

I have this sort of a thing:
Victorian Hat Black - shop[4] - 650 -
Victorian Hat White - shop[4] - 650 -
Victorian Hat Green - shop[4] - 650 -
Victorian Hat Beige - shop[4] - 650 -

I want the last - removed, because it's pointless, but it is followed
by a space.
Graham Mayor;433843 Wrote:
'Line' is a vague concept in Word as lines are totally dependent on
text

flow and content. Are these 'lines' in fact paragraphs - terminated
with a
paragraph mark ¶? In which case the following macro will both remove
any
empty paragraphs and remove the last two characters (excluding the
paragraph
mark) of each line

Sub Remove2Chars()
Dim oRng As Range
Dim i As Long
With ActiveDocument
For i = .Paragraphs.Count To 1 Step -1
Set oRng = .Paragraphs(i).Range
With oRng
.End = .End - 1
If .Text = "" Then .Delete
.Characters.Last.Delete
.Characters.Last.Delete
End With
Next i
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jgrant wrote:-
Alright, and how do I make it remove the last 2 characters? They are
usually a - and a space, but it is sometimes something else, so I
need
it to remove the last 2 characters.
DeanH;432759 Wrote:-
Firstly, try the quick and simple, select the text, click on the
Centre align
icon (Ctrl+E), then the Left align icon (Ctrl+L), this usually gets
rid of
any superfluous spaces and tabs from the start and end of paragraphs.
For multiple paragraphs you can use Find/Replace, using ^p^p for the
find
and ^p for the replace, this will get rid of two paragraph marks and
replace
with one.
See http://sbarnhill.mvps.org/WordFAQs/CleanWebText.htm for this and
other
tips, also see http://gregmaxey.mvps.org/Clean_Up_Text.htm for a
macro that
can help if you need to do this a lot.
--
Hope this helps
DeanH


"Jgrant" wrote:
-

Hi

I'm wondering if it's possible to record a macro, or code one, or if
there's some easy function that will remove two characters from the
end
of each line in Word. The lines are all different lengths.

Also, is there anyway to make Word remove blank lines? (No characters
or anything. Just like if you hit enter twice. There's that line with
nothing in it?)




--
Jgrant
- --



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I remove squares and characters mixed in with text? Songbird Microsoft Word Help 3 March 7th 09 09:25 PM
cursor floating on line & characters not typing across line grandyhomeschooler Microsoft Word Help 1 January 8th 09 06:48 AM
Remove single repeating characters Kenbo Microsoft Word Help 1 October 23rd 08 06:20 PM
Remove line of characters inserted by Word 2003 sb2006 Microsoft Word Help 2 October 8th 06 09:40 PM
remove special characters kn Microsoft Word Help 0 May 26th 06 12:38 AM


All times are GMT +1. The time now is 04:09 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"