Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 22 Sep 2008 11:02:14 -0700,    group: microsoft.public.word.vba.general        back       


Current Paragraph   
If you have selected a range in the activedocument, is there a way to know 
the paragraph number (in relation to the whole document) that the selected 
range is in?

If not, is there a simple way to move from the current paragraph to the 
start (or end) of the previous paragraph?  Or the succeeding paragraph?

-- 
Bill @ UAMS
date: Mon, 22 Sep 2008 11:02:14 -0700   author:   BillCPA Bill @ UAMS

Re: Current Paragraph   
Sub ScratchMaco()
Dim oRng As Word.Range
Set oRng = Selection.Range
MsgBox ActiveDocument.Range(0, 
oRng.Paragraphs(1).Range.End).Paragraphs.Count
'Move to the start of the next paragraph
Selection.MoveDown wdParagraph, 1
'Move to the start of the preceding paragraph
Selection.MoveUp wdParagraph, 1
End Sub



BillCPA wrote:
> If you have selected a range in the activedocument, is there a way to
> know the paragraph number (in relation to the whole document) that
> the selected range is in?
>
> If not, is there a simple way to move from the current paragraph to
> the start (or end) of the previous paragraph?  Or the succeeding
> paragraph?

-- 
Greg Maxey -  Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org

McCain/Palin '08 !!!
date: Mon, 22 Sep 2008 15:32:59 -0400   author:   Greg Maxey RrOMEOgOLF

Re: Current Paragraph   
To: Greg Maxey,

Re: MsgBox ActiveDocument.Range(0, _
      oRng.Paragraphs(1).Range.End).Paragraphs.Count

The highest number I'm getting is 4. It seems to work for the first few 
paragraphs, and then after that every paragraph appears to return the number 
4. Am I doing something wrong? Does it work for you?

Steven Craig Miller


"Greg Maxey" wrote:

> Sub ScratchMaco()
> Dim oRng As Word.Range
> Set oRng = Selection.Range
> MsgBox ActiveDocument.Range(0, 
> oRng.Paragraphs(1).Range.End).Paragraphs.Count
> 'Move to the start of the next paragraph
> Selection.MoveDown wdParagraph, 1
> 'Move to the start of the preceding paragraph
> Selection.MoveUp wdParagraph, 1
> End Sub
> 
> 
> 
> BillCPA wrote:
> > If you have selected a range in the activedocument, is there a way to
> > know the paragraph number (in relation to the whole document) that
> > the selected range is in?
> >
> > If not, is there a simple way to move from the current paragraph to
> > the start (or end) of the previous paragraph?  Or the succeeding
> > paragraph?
> 
> -- 
> Greg Maxey -  Word MVP
> 
> My web site http://gregmaxey.mvps.org
> Word MVP web site http://word.mvps.org
> 
> McCain/Palin '08 !!! 
> 
> 
>
date: Mon, 22 Sep 2008 13:13:01 -0700   author:   StevenM stevencraigmiller(at)comcast(dot)net

Re: Current Paragraph   
Steven,

I haven't performed comprehensive testing (just on a half page of gibberish) 
but is seems to work.  It certainly doesn't get hung up on 4.

Sub ScratchMaco()
Dim oRng As Word.Range
Set oRng = Selection.Range
MsgBox ActiveDocument.Range(0, 
oRng.Paragraphs(1).Range.End).Paragraphs.Count
End Sub


StevenM wrote:
> To: Greg Maxey,
>
> Re: MsgBox ActiveDocument.Range(0, _
>      oRng.Paragraphs(1).Range.End).Paragraphs.Count
>
> The highest number I'm getting is 4. It seems to work for the first
> few paragraphs, and then after that every paragraph appears to return
> the number
> 4. Am I doing something wrong? Does it work for you?
>
> Steven Craig Miller
>
>
> "Greg Maxey" wrote:
>
>> Sub ScratchMaco()
>> Dim oRng As Word.Range
>> Set oRng = Selection.Range
>> MsgBox ActiveDocument.Range(0,
>> oRng.Paragraphs(1).Range.End).Paragraphs.Count
>> 'Move to the start of the next paragraph
>> Selection.MoveDown wdParagraph, 1
>> 'Move to the start of the preceding paragraph
>> Selection.MoveUp wdParagraph, 1
>> End Sub
>>
>>
>>
>> BillCPA wrote:
>>> If you have selected a range in the activedocument, is there a way
>>> to know the paragraph number (in relation to the whole document)
>>> that the selected range is in?
>>>
>>> If not, is there a simple way to move from the current paragraph to
>>> the start (or end) of the previous paragraph?  Or the succeeding
>>> paragraph?
>>
>> --
>> Greg Maxey -  Word MVP
>>
>> My web site http://gregmaxey.mvps.org
>> Word MVP web site http://word.mvps.org
>>
>> McCain/Palin '08 !!!

-- 
Greg Maxey -  Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org

McCain/Palin '08 !!!
date: Mon, 22 Sep 2008 16:21:08 -0400   author:   Greg Maxey RrOMEOgOLF

Re: Current Paragraph   
To: Greg,

I found my mistake. <sigh> The document I was testing it on had used 
vertical line feeds rather than paragraph marks. Egg on my face.

Steven Craig Miller
 
"Greg Maxey" wrote:

> Steven,
> 
> I haven't performed comprehensive testing (just on a half page of gibberish) 
> but is seems to work.  It certainly doesn't get hung up on 4.
> 
> Sub ScratchMaco()
> Dim oRng As Word.Range
> Set oRng = Selection.Range
> MsgBox ActiveDocument.Range(0, 
> oRng.Paragraphs(1).Range.End).Paragraphs.Count
> End Sub
> 
> 
> StevenM wrote:
> > To: Greg Maxey,
> >
> > Re: MsgBox ActiveDocument.Range(0, _
> >      oRng.Paragraphs(1).Range.End).Paragraphs.Count
> >
> > The highest number I'm getting is 4. It seems to work for the first
> > few paragraphs, and then after that every paragraph appears to return
> > the number
> > 4. Am I doing something wrong? Does it work for you?
> >
> > Steven Craig Miller
> >
> >
> > "Greg Maxey" wrote:
> >
> >> Sub ScratchMaco()
> >> Dim oRng As Word.Range
> >> Set oRng = Selection.Range
> >> MsgBox ActiveDocument.Range(0,
> >> oRng.Paragraphs(1).Range.End).Paragraphs.Count
> >> 'Move to the start of the next paragraph
> >> Selection.MoveDown wdParagraph, 1
> >> 'Move to the start of the preceding paragraph
> >> Selection.MoveUp wdParagraph, 1
> >> End Sub
> >>
> >>
> >>
> >> BillCPA wrote:
> >>> If you have selected a range in the activedocument, is there a way
> >>> to know the paragraph number (in relation to the whole document)
> >>> that the selected range is in?
> >>>
> >>> If not, is there a simple way to move from the current paragraph to
> >>> the start (or end) of the previous paragraph?  Or the succeeding
> >>> paragraph?
> >>
> >> --
> >> Greg Maxey -  Word MVP
> >>
> >> My web site http://gregmaxey.mvps.org
> >> Word MVP web site http://word.mvps.org
> >>
> >> McCain/Palin '08 !!!
> 
> -- 
> Greg Maxey -  Word MVP
> 
> My web site http://gregmaxey.mvps.org
> Word MVP web site http://word.mvps.org
> 
> McCain/Palin '08 !!! 
> 
> 
>
date: Mon, 22 Sep 2008 13:56:18 -0700   author:   StevenM stevencraigmiller(at)comcast(dot)net

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us