Group:  Microsoft Word ยป microsoft.public.word.vba.customization
Thread: Make "Selection.TypeParagraph" work if text, not work if just retu

Make "Selection.TypeParagraph" work if text, not work if just retu
NetCow 10/17/2008 7:17:02 PM
' If Subhead
ElseIf Selection.Text <> " " And Selection.Font.Size = 10 And
Selection.Font.Bold = True Then
' Tag Subhead
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="#####"
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="#####"
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1
** Selection.TypeParagraph
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Else
Selection.MoveDown Unit:=wdParagraph, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End If
Wend
' Remove # and add line
Selection.TypeParagraph

** If there is already a 'blank line' next (just a paragraph mark after a
'subhead') I do not want a paragraph return added. I only want one added when
a line of text follows a 'subhead'
Re: Make "Selection.TypeParagraph" work if text, not work if just retu
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 10/17/2008 7:39:42 PM
It would be easier if you told us what you want to do rather than have us
try to figure it out from your code, which is almost certainly not the way
that it should be done.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"NetCow" <NetCow[ at ]discussions.microsoft.com> wrote in message
news:FDD2D4F6-3B2A-4B6E-9D32-EB42DF70BB6C[ at ]microsoft.com...
[Quoted Text]
>' If Subhead
> ElseIf Selection.Text <> " " And Selection.Font.Size = 10 And
> Selection.Font.Bold = True Then
> ' Tag Subhead
> Selection.EndKey Unit:=wdLine
> Selection.TypeText Text:="#####"
> Selection.HomeKey Unit:=wdLine
> Selection.TypeText Text:="#####"
> Selection.HomeKey Unit:=wdLine
> Selection.MoveDown Unit:=wdLine, Count:=1
> ** Selection.TypeParagraph
> Selection.MoveRight Unit:=wdCharacter, Count:=1,
> Extend:=wdExtend
> Else
> Selection.MoveDown Unit:=wdParagraph, Count:=1
> Selection.HomeKey Unit:=wdLine
> Selection.MoveRight Unit:=wdCharacter, Count:=1,
> Extend:=wdExtend
> End If
> Wend
> ' Remove # and add line
> Selection.TypeParagraph
>
> ** If there is already a 'blank line' next (just a paragraph mark after a
> 'subhead') I do not want a paragraph return added. I only want one added
> when
> a line of text follows a 'subhead'


Re: Make "Selection.TypeParagraph" work if text, not work if just
NetCow 10/17/2008 8:08:09 PM
oy. It's a HUGE macro that I am trying to modify. The part i need to modify
was written to insert a paragraph after a subhead in a file that did not
start out with a paragraph after a subhead.

I still need it to do that, but I now also need it to _not_ insert a
paragraph after a subhead in a file that starts out with a paragraph after a
subhead.

I was told by my Powers That Be to replace "Selection.TypeParagraph"
with
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Text <> " " Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
Else
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End If

but the paragraph mark is still added, resulting in 2 paragraph marks.

I am thinking that it can't be done without totally changing the existing
macro and I am not empowered to do that or to get it done.

I was just hoping beyond hope that it was just a tweak or a misplaced
something in this little code snippet that could be fixed or whatever and
then it would work.

thank you for your time.

"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> It would be easier if you told us what you want to do rather than have us
> try to figure it out from your code, which is almost certainly not the way
> that it should be done.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
Re: Make "Selection.TypeParagraph" work if text, not work if just
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 10/18/2008 6:49:06 AM
And precisely what do you mean by the term "subhead"? It is not a defined
term in Word. Is it a particular Heading Style and what you want to do is
insert an empty paragraph if it is followed immediately by a paragraph with
the same Heading Style.

And do you actually want an empty paragraph or is what you are really trying
to do is have the paragraph that has the Heading Style appear with some
space after it.

And where you do not want to insert a paragraph (in your terms" _not_insert
a paragraph") is that because there is already and empty paragraph after
that Heading Style and before the next paragraph containing text.

If you want help that is of use to you, you must tell us, in meaningful
terms, and by that I mean in terms such as those that are used Word, exactly
what it is that you have and exactly what it is that you want to have.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"NetCow" <NetCow[ at ]discussions.microsoft.com> wrote in message
news:F09EE7AC-904C-468E-8FF3-C5D6DB8FE144[ at ]microsoft.com...
[Quoted Text]
> oy. It's a HUGE macro that I am trying to modify. The part i need to
> modify
> was written to insert a paragraph after a subhead in a file that did not
> start out with a paragraph after a subhead.
>
> I still need it to do that, but I now also need it to _not_ insert a
> paragraph after a subhead in a file that starts out with a paragraph after
> a
> subhead.
>
> I was told by my Powers That Be to replace "Selection.TypeParagraph"
> with
> Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
> If Selection.Text <> " " Then
> Selection.MoveLeft Unit:=wdCharacter, Count:=1
> Selection.TypeParagraph
> Else
> Selection.MoveLeft Unit:=wdCharacter, Count:=1
> End If
>
> but the paragraph mark is still added, resulting in 2 paragraph marks.
>
> I am thinking that it can't be done without totally changing the existing
> macro and I am not empowered to do that or to get it done.
>
> I was just hoping beyond hope that it was just a tweak or a misplaced
> something in this little code snippet that could be fixed or whatever and
> then it would work.
>
> thank you for your time.
>
> "Doug Robbins - Word MVP" wrote:
>
>> It would be easier if you told us what you want to do rather than have us
>> try to figure it out from your code, which is almost certainly not the
>> way
>> that it should be done.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP


Home | Search | Terms | Imprint
Newsgroups Reader