Word 2007 Deleting across paragraphs does not delete paragraph mar

A

ATD

If I select from the middle of one paragraph to the middle of another
paragraph and then press Delete, I expect selection to be removed and the
remaining parts of the paragraphs to be merged into one. However, Word 2007
removes the text but inserts a paragraph mark to leave me with two paragraphs
still. This is not how it used to be and not what I want it to be but I can
not find a way to stop it doing this. It's bad enough to have to manually
delete the new paragraph mark, but we have many hundreds of templates
controlled by macros that are being badly affected by this.

How do I stop Word inserting a paragraph mark?
 
S

Suzanne S. Barnhill

There are a number of "smart" options that you might experiment with to see
which one might be causing this behavior. In Office Button | Word Options |
Advanced: Cut, copy, and paste, look at the settings for "Smart cut and
paste." Under "Editing options," I found that I had to disable "Use smart
paragraph selection," but I don't remember why.

FWIW, when I select parts of two successive paragraphs and delete them, the
selection is deleted, but the text remains in two paragraphs, so whatever I
have done so far hasn't solved the problem you describe. And this *is* a
change from Word 2003.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
L

Lene Fredborg

I had not registered that strange and new behavior until reading your post. I
have not yet registered problems with any of my huge amount of macros due to
this but this could very easily happen. I agree with you that one expects the
selection to be totally deleted when one selects Delete (as it works in
previous versions of Word). The behavior could be “by design†– e.g. to
preserve the applied paragraph styles. I cannot find any built-in options
that change the way it works.

In macros containing code to delete content that spans two or more
paragraphs without necessarily including the entire first and last
paragraphs, the only solution I can think of now is to treat the deletion via
special macro code (the problem with the left over paragraph mark applies no
matter whether you use Selection or Range when deleting). The following macro
should delete the remaining paragraph mark together with the remainder of the
selection (I have tried to make the macro so that it will not make any harm
if used in earlier versions of Word):


Sub DeleteEntireSelection_Word2007()
Dim oRange As Range
Dim nParas As Long
Dim bFirstParaIncluded As Boolean
Dim bLastParaIncluded As Boolean

Set oRange = Selection.Range

With oRange
nParas = .Paragraphs.Count

'Find out whether entire first and last paragraph is in selection
bFirstParaIncluded =
..Paragraphs.First.Range.Characters.First.InRange(oRange)
bLastParaIncluded =
..Paragraphs.Last.Range.Characters.Last.InRange(oRange)

.Delete

'In case of Word 2007:
'If original selection spans more than 1 paragraph
'and if entire first and last paragraphs are not in the selection,
'a paragraph mark is left - delete it
If Val(Application.Version) > 11 Then
'Only needed to check if more than one paragraph is selected
If nParas > 1 Then
If bFirstParaIncluded = False And bLastParaIncluded = False
Then
Selection.Characters(1).Delete
End If
End If
End If
End With

'Clean up
Set oRange = Nothing
End Sub

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Greg Maxey

I had not registered that strange and new behavior until reading your post. I
have not yet registered problems with any of my huge amount of macros dueto
this but this could very easily happen. I agree with you that one expectsthe
selection to be totally deleted when one selects Delete (as it works in
previous versions of Word). The behavior could be “by design” – e.g.. to
preserve the applied paragraph styles. I cannot find any built-in options
that change the way it works.

In macros containing code to delete content that spans two or more
paragraphs without necessarily including the entire first and last
paragraphs, the only solution I can think of now is to treat the deletionvia
special macro code (the problem with the left over paragraph mark appliesno
matter whether you use Selection or Range when deleting). The following macro
should delete the remaining paragraph mark together with the remainder ofthe
selection (I have tried to make the macro so that it will not make any harm
if used in earlier versions of Word):

Sub DeleteEntireSelection_Word2007()
    Dim oRange As Range
    Dim nParas As Long
    Dim bFirstParaIncluded As Boolean
    Dim bLastParaIncluded As Boolean

    Set oRange = Selection.Range

    With oRange
        nParas = .Paragraphs.Count

        'Find out whether entire first and last paragraph is in selection
        bFirstParaIncluded =
.Paragraphs.First.Range.Characters.First.InRange(oRange)
        bLastParaIncluded =
.Paragraphs.Last.Range.Characters.Last.InRange(oRange)

        .Delete

        'In case of Word 2007:
        'If original selection spans more than 1 paragraph
        'and if entire first and last paragraphs are not in the selection,
        'a paragraph mark is left - delete it
        If Val(Application.Version) > 11 Then
            'Only needed to check if more than one paragraph is selected
            If nParas > 1 Then
                If bFirstParaIncluded = False And bLastParaIncluded = False
Then
                    Selection.Characters(1).Delete
                End If
            End If
        End If
    End With

    'Clean up
    Set oRange = Nothing
End Sub

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word






- Show quoted text -

How about:

Sub ScracthMacro()
If InStr(Selection.Text, Chr(13)) > 1 Then
Selection.Text = Replace(Selection.Text, Chr(13), " ")
Selection.Delete
End If
End Sub
 
G

Graham Mayor

Greg said:
How about:

Sub ScracthMacro()
If InStr(Selection.Text, Chr(13)) > 1 Then
Selection.Text = Replace(Selection.Text, Chr(13), " ")
Selection.Delete
End If
End Sub

Sub ScratchMacro()
If InStr(Selection.Text, Chr(13)) Then
Selection.Text = Replace(Selection.Text, Chr(13), " ")
End If
Selection.Delete
End Sub

Would delete the selected text whether or not the selection contained a
paragraph break which is closer to the Word 2003 behaviour.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

ATD

Thanks all - I have already updated my macros to replace paragraphs marks
with spaces and that does work, of course. However, for my users, they still
have the pain of having to perform the selection delete and then delete the
inserted paragraph mark when they do this manually.

Surely, Microsoft can't believe that "delete this bit" means "We'll delete
it but add something in because you will always need it and, no, you can't
switch this off"???

Andy
 
L

Lene Fredborg

Hi Greg and Graham,

Much easier and much better to do it in that order…

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
L

Lene Fredborg

Possible solution:
The command executed when pressing the Delete key is EditClear. You could
rename the deletion macro to EditClear and it will run instead of the
built-in command.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Graham Mayor

Whether this is 'by design' I cannot say, but here is a certain logic in it.
The formatting associated with a paragraph is stored in the paragraph break.
By retaining that paragraph break the formatting of the two parts is
retained.

There is less 'pain' if instead of pressing 'delete' or 'backspace', the
users press 'space' then 'backspace'.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

I had been racking my brains to think what the delete key command was -
Renaming the macro works just fine :)

Sub EditClear()
If InStr(Selection.Text, Chr(13)) Then
Selection.Text = Replace(Selection.Text, Chr(13), " ")
End If
Selection.Delete
End Sub

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
L

Lene Fredborg

I found the answer via the Shortcut Key dialog box ;-)

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Graham Mayor

There is a snag - it doesn't work in protected form fields without
additional programming.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Cheryl Flanders

If you place your cursor at the end of a word, then select text to the
immediate left of a word in the next paragraph, you can hit the
spacebar instead of the delete key. This keeps the spacing correct
without a paragraph mark and no need for a macro.

Cheryl
 
S

Suzanne S. Barnhill

Indeed, this does work and may be the only satisfactory solution.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

If you place your cursor at the end of a word, then select text to the
immediate left of a word in the next paragraph, you can hit the
spacebar instead of the delete key. This keeps the spacing correct
without a paragraph mark and no need for a macro.

Cheryl
 
L

Lene Fredborg

That is true. However, users are used to press Delete to delete something and
you may not always need to delete entire words. You would then need to press
Backspace afterwards to delete the space (Graham suggested that procedure
too).

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
L

Lene Fredborg

You are right. And there is more…

Further observations:
In a protected form, deletion via the Delete key (without the macro) works
as in 2003 as far as I can see. The paragraph mark is gone after pressing
Delete.

Before I posted my macro, I tested it with tables fully or partly selected
and both with and without having selected text before or after the table. The
macro seems to work as "normal" delete (i.e. 2003 delete). I have now found
out that your version fails if part of a table is selected in combination
with text before the table. And if only part of a table is selected (without
text before or after), the result is not correct - or maybe it is better so
say it this way: the result is not the same as if one used the Delete key in
2003 or in 2007.

Another problem: even if the macro(s) were changed to handle the above, the
user would have to press Undo at least twice to undo the deletion (unless
Undo handling is also built into the macro).

All in all, I think I would skip the idea of using a macro – and then I
would prefer pressing Delete twice to overcome the problem with the paragraph
mark <g>

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Graham Mayor

I agree. I have already abandoned the macro. Given the number of times I
delete text across paragraphs I can live with this anomaly.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

ATD

Hi Graham

MS go to great pains to warn you about what happens when you delete
paragraph marks - and then they go and stop you doing it without, as far as
I've been able to make out, any way to switching that off. Another instance
of them assuming that we're all idiots and don't know what we're doing!
Whilst some of my users may fall into that category, I'm don't, but I'm
rapidly running out of patience with 2007 and all the "defaults" that you
can't do anything about.

Whilst the space/backspace suggestion would probably work ok, it is still
just a workaround to a problem that MS have created and needn't have done.

Andy
 

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